<?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: Help Transforming JSON in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Help-Transforming-JSON/m-p/209996#M171945</link>
    <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/641/mburgess.html" nodeid="641"&gt;@Matt Burgess&lt;/A&gt; ,&lt;/P&gt;&lt;P&gt;i think i will try to do this as suggested by Bryan some where else..&lt;/P&gt;&lt;P&gt;You can use MergeContent and set the Delimiter Strategy to "Text" and then enter [ , ] for the header, demarcator, and footer respectively...i think it should work.&lt;/P&gt;</description>
    <pubDate>Tue, 12 Jun 2018 04:04:11 GMT</pubDate>
    <dc:creator>saikrishna_tara</dc:creator>
    <dc:date>2018-06-12T04:04:11Z</dc:date>
    <item>
      <title>Help Transforming JSON</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Help-Transforming-JSON/m-p/209992#M171941</link>
      <description>&lt;P&gt;
	Hi,&lt;/P&gt;&lt;P&gt;
	i need to transform the input JSON below&lt;/P&gt;&lt;P&gt;{
  "TransactionId": "-1",
  "Source": "ihrs",
  "Name": "tag-data",
  "Id": "126",
  "Records": [
    {
      "Name": "tag-master",
      "PayLoad": {
        "file-name": "testfile.json",
        "plant": "1086",
        "collector": "testcollector",
        "tag-name": "testtag",
        "tag-description": "test desc"
      }
    },
    {
      "Name": "tag-detail",
      "PayLoad": {
        "tag-value": "98998.55",
        "tag-timestamp": "2018-01-02T16:09:39.000000+00:00",
        "tag-quality": "100"
      }
    },
    {
      "Name": "tag-detail",
      "PayLoad": {
        "tag-value": "91009.47",
        "tag-timestamp": "2018-01-02T16:09:340000000+00:00",
        "tag-quality": "100"
      }
    },
    {
      "Name": "tag-detail",
      "PayLoad": {
        "tag-value": "91021.80",
        "tag-timestamp": "2018-01-02T16:09:41.000000+00:00",
        "tag-quality": "100"
      }
    }
  ]
}&lt;/P&gt;&lt;P&gt;to output like below. &lt;/P&gt;&lt;P&gt;{
  "TransactionId": "-1",
  "Source": "ihrs",
  "Name": "tag-data",
  "Id": "100",
  "Records": [
    {
      "Name": "tag-master",
      "PayLoad": {
        "file-name": "testfile.json",
        "plant": "1000",
        "collector": "testcollector",
        "tag-name": "testtag",
        "tag-description": "test desc",
        "Children": [
          {
            "Name": "tag-detail",
            "PayLoad": {
              "tag-value": "98998.55",
              "tag-timestamp": "2018-01-02T16:09:39.000000+00:00",
              "tag-quality": "100"
            }
          },
          {
            "Name": "tag-detail",
            "PayLoad": {
              "tag-value": "98998.55",
              "tag-timestamp": "2018-01-02T16:09:39.000000+00:00",
              "tag-quality": "100"
            }
          }
        ]
      }
    }
  ]
}&lt;/P&gt;&lt;P&gt;i need to move the details records under master as array..
basically first element of the record array (tag master)is parent to next 3 elements(tag details). i tried to use the convert record processor with JSON converters giving correct input and output schemas for files. it didnt convert. it looks like i may have to write JOLT which i need some help with.
Thanks in advance!!!&lt;/P&gt;&lt;P&gt;attached files for reference..&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.cloudera.com/legacyfs/online/attachments/76594-input.json"&gt;input.json&lt;/A&gt;&lt;A href="https://community.cloudera.com/legacyfs/online/attachments/76595-output.json"&gt;output.json&lt;/A&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Regards,
Sai&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jun 2018 23:45:10 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Help-Transforming-JSON/m-p/209992#M171941</guid>
      <dc:creator>saikrishna_tara</dc:creator>
      <dc:date>2018-06-06T23:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: Help Transforming JSON</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Help-Transforming-JSON/m-p/209993#M171942</link>
      <description>&lt;P&gt;Try this Chain spec in JoltTransformJSON:&lt;/P&gt;&lt;PRE&gt;[
  {
    "operation": "shift",
    "spec": {
      "Records": {
        "*": {
          "Name": {
            "tag-master": {
              "@2": "Records[&amp;amp;3]"
            },
            "*": {
              "@2": "Records[#3].PayLoad.Children[]"
            }
          }
        }
      },
      "*": "&amp;amp;"
    }
  }
]&lt;/PRE&gt;&lt;P&gt;It matches tag-master separately, puts it back into the Records array as-is, then for each tag-detail match, puts it into a Children array in the tag-master's PayLoad object.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 01:41:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Help-Transforming-JSON/m-p/209993#M171942</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2018-06-07T01:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: Help Transforming JSON</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Help-Transforming-JSON/m-p/209994#M171943</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/641/mburgess.html" nodeid="641"&gt;@Matt Burgess&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 03:57:57 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Help-Transforming-JSON/m-p/209994#M171943</guid>
      <dc:creator>saikrishna_tara</dc:creator>
      <dc:date>2018-06-08T03:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: Help Transforming JSON</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Help-Transforming-JSON/m-p/209995#M171944</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/641/mburgess.html" nodeid="641"&gt;@Matt Burgess&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;I have another challenge that i need to merge these smaller JSON files in to 1 file. lets say i need to merge 1000 files that i get from above JOLT in to one single json file and load in to HDFS. &lt;/P&gt;&lt;P&gt;how can i do that as the input files will be combined one after other using the MergeContent processor and the resulting file wont be a valid one.&lt;/P&gt;&lt;P&gt;any idea how to solve this.?&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sai&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 03:55:20 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Help-Transforming-JSON/m-p/209995#M171944</guid>
      <dc:creator>saikrishna_tara</dc:creator>
      <dc:date>2018-06-12T03:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: Help Transforming JSON</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Help-Transforming-JSON/m-p/209996#M171945</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/641/mburgess.html" nodeid="641"&gt;@Matt Burgess&lt;/A&gt; ,&lt;/P&gt;&lt;P&gt;i think i will try to do this as suggested by Bryan some where else..&lt;/P&gt;&lt;P&gt;You can use MergeContent and set the Delimiter Strategy to "Text" and then enter [ , ] for the header, demarcator, and footer respectively...i think it should work.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 04:04:11 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Help-Transforming-JSON/m-p/209996#M171945</guid>
      <dc:creator>saikrishna_tara</dc:creator>
      <dc:date>2018-06-12T04:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: Help Transforming JSON</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Help-Transforming-JSON/m-p/209997#M171946</link>
      <description>&lt;P&gt;You're probably better served with MergeRecord, that will output the merged JSON records as an array&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 20:47:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Help-Transforming-JSON/m-p/209997#M171946</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2018-06-12T20:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: Help Transforming JSON</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Help-Transforming-JSON/m-p/209998#M171947</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/641/mburgess.html" nodeid="641"&gt;@Matt Burgess&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;Can you please explain how can we do this using mergerecord as I am not able to to do it..&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 18:31:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Help-Transforming-JSON/m-p/209998#M171947</guid>
      <dc:creator>rajatpuchnanda1</dc:creator>
      <dc:date>2018-06-19T18:31:27Z</dc:date>
    </item>
    <item>
      <title>Re: Help Transforming JSON</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Help-Transforming-JSON/m-p/209999#M171948</link>
      <description>&lt;P&gt;I recommend using MergeRecord before the JoltTransformJSON as the Jolt transform should be able to be applied to the whole JSON array (after your smaller JSON objects have been merged). You'll want to use a JsonTreeRecordReader and provide an Avro schema that matches your input data above. &lt;A href="https://community.cloudera.com/legacyfs/online/attachments/77753-mergerecord-example.xml"&gt;mergerecord-example.xml&lt;/A&gt; is an example template where I generate data similar to yours, use MergeRecord to bundle them 20 at a time, then run the Jolt spec on it, it includes the associated Avro schema and hopefully all config to get you up and going.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jun 2018 00:36:58 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Help-Transforming-JSON/m-p/209999#M171948</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2018-06-20T00:36:58Z</dc:date>
    </item>
  </channel>
</rss>

