<?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>question Re: How tho convert JSON format in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-tho-convert-JSON-format/m-p/195397#M62365</link>
    <description>&lt;P&gt;Hi Matt,
great solution!!!&lt;/P&gt;&lt;P&gt;Thanks
Timo&lt;/P&gt;</description>
    <pubDate>Tue, 06 Jun 2017 15:58:38 GMT</pubDate>
    <dc:creator>timo_burmeister</dc:creator>
    <dc:date>2017-06-06T15:58:38Z</dc:date>
    <item>
      <title>How tho convert JSON format</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-tho-convert-JSON-format/m-p/195395#M62363</link>
      <description>&lt;P&gt;The system produced in the 1 line the keys und in the next lines the values:&lt;/P&gt;&lt;PRE&gt;[
 [
  "host_state",
  "host",
  "host_icons",
  "num_services_ok",
  "num_services_warn",
  "num_services_unknown",
  "num_services_crit",
  "num_services_pending"
 ],
 [
  "UP",
  "DUSTSADMIN.ads.xyz.de",
  "menu",
  "28",
  "0",
  "0",
  "0",
  "0"
 ],
 [
  "UP",
  "DUSTSVMDC01.ads.xyz.de",
  "menu",
  "34",
  "0",
  "0",
  "0",
  "0"
 ],
 [
  "UP",
  "DUSTSVMDC02.ads.xyz.de",
  "menu",
  "34",
  "0",
  "0",
  "0",
  "0"
 ]
 
How to convert to key=value structure ?:

{
	"host_state":"UP",
	"host":"DUSTSVMDC01.ads.xyz.de",
 	"host_icons":"menu",
  	"num_services_ok":"28",
  	"num_services_warn":"0",
  	"num_services_unknown":"0",
  	"num_services_crit":"0",
  	"num_services_pending":"0",
}&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Jun 2017 19:31:45 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-tho-convert-JSON-format/m-p/195395#M62363</guid>
      <dc:creator>timo_burmeister</dc:creator>
      <dc:date>2017-06-05T19:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: How tho convert JSON format</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-tho-convert-JSON-format/m-p/195396#M62364</link>
      <description>&lt;P&gt;You can use the JoltTransformJSON processor for this. Here is a Chain spec that should get you what you want:&lt;/P&gt;&lt;PRE&gt;[
  {
    "operation": "shift",
    "spec": {
      "0": {
        "*": "header"
      },
      "*": "data[]"
    }
  },
  {
    "operation": "shift",
    "spec": {
      "data": {
        "*": {
          "*": {
            "@0": "[&amp;amp;2].@(4,header[&amp;amp;])"
          }
        }
      }
    }
  }
]&lt;/PRE&gt;&lt;P&gt;The first operation splits the top array into "header" (containing the first element) and "data" (containing the rest). The second operation creates an array of objects, each object having the keys from the header associated with the values from each element in the "data" array.  With your input above, I get the following output:&lt;/P&gt;&lt;PRE&gt;[ {
  "host" : "DUSTSADMIN.ads.xyz.de",
  "host_icons" : "menu",
  "host_state" : "UP",
  "num_services_crit" : "0",
  "num_services_ok" : "28",
  "num_services_pending" : "0",
  "num_services_unknown" : "0",
  "num_services_warn" : "0"
}, {
  "host" : "DUSTSVMDC01.ads.xyz.de",
  "host_icons" : "menu",
  "host_state" : "UP",
  "num_services_crit" : "0",
  "num_services_ok" : "34",
  "num_services_pending" : "0",
  "num_services_unknown" : "0",
  "num_services_warn" : "0"
}, {
  "host" : "DUSTSVMDC02.ads.xyz.de",
  "host_icons" : "menu",
  "host_state" : "UP",
  "num_services_crit" : "0",
  "num_services_ok" : "34",
  "num_services_pending" : "0",
  "num_services_unknown" : "0",
  "num_services_warn" : "0"
} ]
&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Jun 2017 20:58:18 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-tho-convert-JSON-format/m-p/195396#M62364</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2017-06-05T20:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: How tho convert JSON format</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-tho-convert-JSON-format/m-p/195397#M62365</link>
      <description>&lt;P&gt;Hi Matt,
great solution!!!&lt;/P&gt;&lt;P&gt;Thanks
Timo&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2017 15:58:38 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-tho-convert-JSON-format/m-p/195397#M62365</guid>
      <dc:creator>timo_burmeister</dc:creator>
      <dc:date>2017-06-06T15:58:38Z</dc:date>
    </item>
  </channel>
</rss>

