<?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: using outputMode JSON and using multivalued fields in the REST API in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/using-outputMode-JSON-and-using-multivalued-fields-in-the-REST/m-p/107856#M22676</link>
    <description>&lt;P&gt;json_cols is a well supported output mode, and the one that's used by our Highchart based charting library. We'd consider it a bug that we're reporting the wrong content type.&lt;/P&gt;

&lt;P&gt;The plain JSON output is being fixed to emit proper multivalued fields, but you can be confident in your use of json_cols.&lt;/P&gt;</description>
    <pubDate>Fri, 26 Jul 2013 18:29:04 GMT</pubDate>
    <dc:creator>Stephen_Sorkin</dc:creator>
    <dc:date>2013-07-26T18:29:04Z</dc:date>
    <item>
      <title>using outputMode JSON and using multivalued fields in the REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/using-outputMode-JSON-and-using-multivalued-fields-in-the-REST/m-p/107855#M22675</link>
      <description>&lt;P&gt;Does anyone know any way to tickle outputMode json in the Splunk REST API, such that it will actually give back multivalue field values, appropriately separated?   &lt;/P&gt;

&lt;P&gt;OutputMode XML divides up the individual values nicely. Here's what you get for a single result row (coming off &lt;CODE&gt;index=_internal group="per_*_thruput" | head 1000 | stats values(group) as group&lt;/CODE&gt;)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;result offset="0"&amp;gt;
  &amp;lt;field k="groups"&amp;gt;
    &amp;lt;value&amp;gt;
      &amp;lt;text&amp;gt;per_host_thruput&amp;lt;/text&amp;gt;
    &amp;lt;/value&amp;gt;
    &amp;lt;value&amp;gt;
      &amp;lt;text&amp;gt;per_index_thruput&amp;lt;/text&amp;gt;
    &amp;lt;/value&amp;gt;
    &amp;lt;value&amp;gt;
      &amp;lt;text&amp;gt;per_source_thruput&amp;lt;/text&amp;gt;
    &amp;lt;/value&amp;gt;
    &amp;lt;value&amp;gt;
      &amp;lt;text&amp;gt;per_sourcetype_thruput&amp;lt;/text&amp;gt;
    &amp;lt;/value&amp;gt;
  &amp;lt;/field&amp;gt;
&amp;lt;/result&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(indentation added)&lt;/P&gt;

&lt;P&gt;but outputMode json just joins the values together on space and gives back a giant string...   &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[{"groups": "per_host_thruput per_index_thruput per_source_thruput per_sourcetype_thruput"}]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which seriously limits my options.   (If I knew that the values didn't themselves contain spaces then I could split on space, but this is framework code and that's not an option)&lt;/P&gt;

&lt;P&gt;Apparently there's an outputmode=json_cols, at least in 5.0 and up.  And the same results in that mode are: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
"preview":false,
"init_offset":0,
"messages":[
    {"type":"DEBUG","text":"base lispy: [ AND index::_internal per source::*metrics.log thruput ]"},
    {"type":"DEBUG","text":"search context: user=\"admin\", app=\"sideview_utils\", bs-pathname=\"C:\\Program Files\\Splunk\\etc\""}
  ],
"fields":["groups"],
"columns":[
    [
      ["per_host_thruput","per_index_thruput","per_source_thruput","per_sourcetype_thruput"]
    ]
  ]
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(indentation added)&lt;/P&gt;

&lt;P&gt;As you can see, it does split up the multivalue values nicely.  However when you use this outputMode on SplunkWeb, the server still sends back content type of text/xml,  which of course triggers parse errors in any client that pays attention to the response headers...   Which doesn't give a lot of confidence.  &lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;So is there any known workaround here for someone wanting to use the REST API and wanting to rretrieve multivalue field values? &lt;/LI&gt;
&lt;LI&gt;Is json_cols considered a better and more stable outputmode then outputMode json or is json_cols still experimental?   I dont want to port all my code to use a new outputformat just for this, if that new outputformat isn't fully baked or supported.&lt;BR /&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:26:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/using-outputMode-JSON-and-using-multivalued-fields-in-the-REST/m-p/107855#M22675</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2020-09-28T14:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: using outputMode JSON and using multivalued fields in the REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/using-outputMode-JSON-and-using-multivalued-fields-in-the-REST/m-p/107856#M22676</link>
      <description>&lt;P&gt;json_cols is a well supported output mode, and the one that's used by our Highchart based charting library. We'd consider it a bug that we're reporting the wrong content type.&lt;/P&gt;

&lt;P&gt;The plain JSON output is being fixed to emit proper multivalued fields, but you can be confident in your use of json_cols.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2013 18:29:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/using-outputMode-JSON-and-using-multivalued-fields-in-the-REST/m-p/107856#M22676</guid>
      <dc:creator>Stephen_Sorkin</dc:creator>
      <dc:date>2013-07-26T18:29:04Z</dc:date>
    </item>
  </channel>
</rss>

