<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: json_extend Scalar Bug, or Coercing JSON Scalars into JSON Arrays in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/json-extend-Scalar-Bug-or-Coercing-JSON-Scalars-into-JSON-Arrays/m-p/756496#M243106</link>
    <description>&lt;P&gt;So much feedback for the new documentation SPA. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; Edit: I've posted feedback. Pre-Cisco, feedback was very effective; I've not submitted anything since the acquisition, so we'll see! Grammar and syntax have taken a downturn over the last year or so.&lt;/P&gt;</description>
    <pubDate>Sun, 14 Dec 2025 14:25:34 GMT</pubDate>
    <dc:creator>tscroggins</dc:creator>
    <dc:date>2025-12-14T14:25:34Z</dc:date>
    <item>
      <title>json_extend Scalar Bug, or Coercing JSON Scalars into JSON Arrays</title>
      <link>https://community.splunk.com/t5/Splunk-Search/json-extend-Scalar-Bug-or-Coercing-JSON-Scalars-into-JSON-Arrays/m-p/756489#M243100</link>
      <description>&lt;P&gt;Hi Splunkers!&lt;/P&gt;&lt;P&gt;In the current json_extend documentation &amp;lt;&lt;A href="https://help.splunk.com/en/splunk-enterprise/spl-search-reference/10.0/evaluation-functions/json-functions" target="_self"&gt;https://help.splunk.com/en/splunk-enterprise/spl-search-reference/10.0/evaluation-functions/json-functions&lt;/A&gt;&amp;gt;, if &amp;lt;path&amp;gt; specifies "a scalar or object value," the value should be "[autowrapped] ... within an array;" however, this doesn't appear to be the case:&lt;/P&gt;&lt;P&gt;| makeresults&lt;BR /&gt;| eval obj=json_object("foo", "bar") ``` or obj="{\"foo\":\"bar\"}" ```&lt;BR /&gt;| eval arr=json_extend(obj, "foo", json_array("baz")) ``` or arr=json_extend(obj, "foo", "[\"baz\"]") ```&lt;/P&gt;&lt;P&gt;If I understand the documentation correctly, "bar" should be coerced to the array ["bar"] and then extended to ["bar","baz"], but it is not. The original object is returned unmodified. json_extend works correctly when the input value is already an array:&lt;/P&gt;&lt;P&gt;| makeresults&lt;BR /&gt;| eval obj=json_object("foo", json_array("bar", "baz"))&lt;BR /&gt;| eval arr=json_extend(obj, "foo", json_array("qux"))&lt;/P&gt;&lt;P&gt;The example was contrived to illustrate the issue. In practice, the value of foo may be either an array or a scalar. For example, the lookup eval function returns a scaler on a single match and an array on multiple matches. json_extract is similarly inconsistent when it returns a Splunk native type for scalars and a string for arrays:&lt;/P&gt;&lt;P&gt;| makeresults&lt;BR /&gt;| eval obj=json_object("foo", "bar")&lt;BR /&gt;| eval val=json_extract(obj, "foo") ``` ==&amp;gt; foo ```&lt;BR /&gt;| eval obj=json_object("foo", json_array("bar", "baz"))&lt;BR /&gt;| eval val=json_extract(obj, "foo") ``` ==&amp;gt; ["bar","baz"] ```&lt;/P&gt;&lt;P&gt;If scalars can be coerced into arrays, values that may be either scalars or arrays can be parsed by json_array_to_mv or other functions without custom wrappers using if, case, replace, etc.&lt;/P&gt;&lt;P&gt;Have you encountered this issue? How have you solved it?&lt;/P&gt;</description>
      <pubDate>Sat, 13 Dec 2025 15:42:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/json-extend-Scalar-Bug-or-Coercing-JSON-Scalars-into-JSON-Arrays/m-p/756489#M243100</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2025-12-13T15:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: json_extend Scalar Bug, or Coercing JSON Scalars into JSON Arrays</title>
      <link>https://community.splunk.com/t5/Splunk-Search/json-extend-Scalar-Bug-or-Coercing-JSON-Scalars-into-JSON-Arrays/m-p/756490#M243101</link>
      <description>&lt;P&gt;I can confirm that it does indeed seem to work not as it is described in the docs. So it warrants a support case.&lt;/P&gt;&lt;P&gt;A walkaround would require some dirty trick with checking whether an element is a scalar or not (possibly with json_array_to_mv(json_extract(...)) and then do json_delete() and json_append(). Very ugly.&lt;/P&gt;</description>
      <pubDate>Sat, 13 Dec 2025 20:21:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/json-extend-Scalar-Bug-or-Coercing-JSON-Scalars-into-JSON-Arrays/m-p/756490#M243101</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-12-13T20:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: json_extend Scalar Bug, or Coercing JSON Scalars into JSON Arrays</title>
      <link>https://community.splunk.com/t5/Splunk-Search/json-extend-Scalar-Bug-or-Coercing-JSON-Scalars-into-JSON-Arrays/m-p/756493#M243103</link>
      <description>&lt;P&gt;This is for me, not a customer; I only have a dev license.&lt;/P&gt;</description>
      <pubDate>Sun, 14 Dec 2025 14:03:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/json-extend-Scalar-Bug-or-Coercing-JSON-Scalars-into-JSON-Arrays/m-p/756493#M243103</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2025-12-14T14:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: json_extend Scalar Bug, or Coercing JSON Scalars into JSON Arrays</title>
      <link>https://community.splunk.com/t5/Splunk-Search/json-extend-Scalar-Bug-or-Coercing-JSON-Scalars-into-JSON-Arrays/m-p/756494#M243104</link>
      <description>&lt;P&gt;You could post a docs feedback instead.&lt;/P&gt;</description>
      <pubDate>Sun, 14 Dec 2025 14:10:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/json-extend-Scalar-Bug-or-Coercing-JSON-Scalars-into-JSON-Arrays/m-p/756494#M243104</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-12-14T14:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: json_extend Scalar Bug, or Coercing JSON Scalars into JSON Arrays</title>
      <link>https://community.splunk.com/t5/Splunk-Search/json-extend-Scalar-Bug-or-Coercing-JSON-Scalars-into-JSON-Arrays/m-p/756496#M243106</link>
      <description>&lt;P&gt;So much feedback for the new documentation SPA. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; Edit: I've posted feedback. Pre-Cisco, feedback was very effective; I've not submitted anything since the acquisition, so we'll see! Grammar and syntax have taken a downturn over the last year or so.&lt;/P&gt;</description>
      <pubDate>Sun, 14 Dec 2025 14:25:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/json-extend-Scalar-Bug-or-Coercing-JSON-Scalars-into-JSON-Arrays/m-p/756496#M243106</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2025-12-14T14:25:34Z</dc:date>
    </item>
    <item>
      <title>Re: json_extend Scalar Bug, or Coercing JSON Scalars into JSON Arrays</title>
      <link>https://community.splunk.com/t5/Splunk-Search/json-extend-Scalar-Bug-or-Coercing-JSON-Scalars-into-JSON-Arrays/m-p/756498#M243107</link>
      <description>&lt;P&gt;The "autowrap" functionality was introduced (according to documentation) in 9.2.0 &amp;lt;&lt;A href="https://help.splunk.com/en/splunk-enterprise/search/spl-search-reference/9.2/evaluation-functions/json-functions" target="_self"&gt;https://help.splunk.com/en/splunk-enterprise/search/spl-search-reference/9.2/evaluation-functions/json-functions&lt;/A&gt;&amp;gt;.&lt;/P&gt;&lt;P&gt;I just tested in 9.2.0.1, and the behavior is the same as 10.0. I'm not going to test every maintenance release between then and now, but I'd guess it's never worked as documented.&lt;/P&gt;</description>
      <pubDate>Sun, 14 Dec 2025 16:49:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/json-extend-Scalar-Bug-or-Coercing-JSON-Scalars-into-JSON-Arrays/m-p/756498#M243107</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2025-12-14T16:49:06Z</dc:date>
    </item>
  </channel>
</rss>

