<?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: Make flat json array from nested one via JOLT in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Make-flat-json-array-from-nested-one-via-JOLT/m-p/344593#M234213</link>
    <description>&lt;P&gt;Actually it is not possible to solve this case in one shift - &lt;A href="https://github.com/bazaarvoice/jolt/issues/1139" target="_blank" rel="noopener"&gt;here&lt;/A&gt; is discussion and workaround with append subarray to mainarray.&lt;/P&gt;</description>
    <pubDate>Fri, 27 May 2022 08:29:39 GMT</pubDate>
    <dc:creator>rustoherox</dc:creator>
    <dc:date>2022-05-27T08:29:39Z</dc:date>
    <item>
      <title>Make flat json array from nested one via JOLT</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Make-flat-json-array-from-nested-one-via-JOLT/m-p/344436#M234169</link>
      <description>&lt;P&gt;Hi everyone!&lt;/P&gt;&lt;P&gt;I'm trying to flat array and it view as simple case, but I can't reach the goal.&lt;/P&gt;&lt;P&gt;Here is simple&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;json input:&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
  "MainArray": {
    "mattr1": "some_value1",
    "mattr2": "some_value2",
    "Subarray": {
         "sattr1": 1,
         "sattr2": 2,
         "sattr3": 3
    }
  }
}&lt;/LI-CODE&gt;&lt;P&gt;Then I would like to convert it to array of arrays [key, value],&lt;BR /&gt;Here is&amp;nbsp;&lt;STRONG&gt;Desired Output:&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
  "ResultArray" : [ 
     [ "mattr1", "some_value1" ], 
     [ "mattr2", "some_value2" ], 
     [ "sattr1", 1 ], 
     [ "sattr2", 2 ], 
     [ "sattr1", 3 ] 
  ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;Here is&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;my spec:&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;[
  {
    "operation": "shift",
    "spec": {
      "MainArray": {
        "*": {
            "$": "ResultArray[#2][0]",
            "@": "ResultArray[#2][1]"
        },
        "Subarray": {
          "*": {
              "$": "ResultArray[#3][#2][0]",
              "@": "ResultArray[#3][#2][1]"
          }
        }
      }
    }
  }
]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;And I don't understand how to fix problem when Subarrays is inside extra array in&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;my result:&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
  "ResultArray" : [ 
     [ "mattr1", "some_value1" ], 
     [ "mattr2", "some_value2" ], 
     [ 
        [ "sattr1", 1 ], 
        [ "sattr2", 2 ], 
        [ "sattr3", 3 ] 
     ] 
  ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;Any advise, please.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 13:21:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Make-flat-json-array-from-nested-one-via-JOLT/m-p/344436#M234169</guid>
      <dc:creator>rustoherox</dc:creator>
      <dc:date>2022-05-25T13:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: Make flat json array from nested one via JOLT</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Make-flat-json-array-from-nested-one-via-JOLT/m-p/344456#M234173</link>
      <description>&lt;P&gt;I'm not sure why your spec is producing this result, but to resolve it you can do the transformation on two shift operations: First to flatting json and move the subarray level to the root level and second to move the result and store it into an Array. Here is the spec I tried and it worked:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[&lt;BR /&gt;{&lt;BR /&gt;"operation": "shift",&lt;BR /&gt;"spec": {&lt;BR /&gt;"MainArray": {&lt;BR /&gt;"*": "ResultArray.&amp;amp;",&lt;BR /&gt;"Subarray": {&lt;BR /&gt;"*": "ResultArray.&amp;amp;"&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"operation": "shift",&lt;BR /&gt;"spec": {&lt;BR /&gt;"ResultArray": {&lt;BR /&gt;"*": {&lt;BR /&gt;"$": "ResultArray[#2][0]",&lt;BR /&gt;"@": "ResultArray[#2][1]"&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 15:03:43 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Make-flat-json-array-from-nested-one-via-JOLT/m-p/344456#M234173</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2022-05-25T15:03:43Z</dc:date>
    </item>
    <item>
      <title>Re: Make flat json array from nested one via JOLT</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Make-flat-json-array-from-nested-one-via-JOLT/m-p/344465#M234177</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;&amp;nbsp;Thank for your variant, but it is not actually desired, because Subarray may be another structure of jolt rules inside for example like this&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;[
  {
    "operation": "shift",
    "spec": {
      "MainArray": {
        "*": {
            "$": "ResultArray[#2][0]",
            "@": "ResultArray[#2][1]"
        },
        "Subarray": {
          "*": {
              "$": "ResultArray[#3][#2][0]",
              "@": "ResultArray[#3][#2][1]",
              "#some_value": "ResultArray[#3][#2][3]"
          }
        }
      }
    }
  }
]&lt;/LI-CODE&gt;&lt;P&gt;Btw it's my fault cause of not actually correct example (same rules for main and sub arrays)&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 16:06:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Make-flat-json-array-from-nested-one-via-JOLT/m-p/344465#M234177</guid>
      <dc:creator>rustoherox</dc:creator>
      <dc:date>2022-05-25T16:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: Make flat json array from nested one via JOLT</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Make-flat-json-array-from-nested-one-via-JOLT/m-p/344593#M234213</link>
      <description>&lt;P&gt;Actually it is not possible to solve this case in one shift - &lt;A href="https://github.com/bazaarvoice/jolt/issues/1139" target="_blank" rel="noopener"&gt;here&lt;/A&gt; is discussion and workaround with append subarray to mainarray.&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 08:29:39 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Make-flat-json-array-from-nested-one-via-JOLT/m-p/344593#M234213</guid>
      <dc:creator>rustoherox</dc:creator>
      <dc:date>2022-05-27T08:29:39Z</dc:date>
    </item>
  </channel>
</rss>

