<?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: Jolt transformation Array to  Flatten in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Jolt-transformation-Array-to-Flatten/m-p/369867#M240579</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;&amp;nbsp;You are a genius. I was caught with the duplicate index array and couldn't resolve.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 03 May 2023 02:11:45 GMT</pubDate>
    <dc:creator>Althotta</dc:creator>
    <dc:date>2023-05-03T02:11:45Z</dc:date>
    <item>
      <title>Jolt transformation Array to  Flatten</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Jolt-transformation-Array-to-Flatten/m-p/369487#M240498</link>
      <description>&lt;P&gt;Hi Jolt Experts,&lt;/P&gt;&lt;P&gt;Iam looking to use the Jolt transformation in NIFI and looking for a help.&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"header": {&lt;BR /&gt;"timeStamp": "1681441547144",&lt;BR /&gt;"activityId": "5142917973836294867"&lt;BR /&gt;},&lt;BR /&gt;"resource": {&lt;BR /&gt;"drniId": "261968731599587823",&lt;BR /&gt;"@type": "Order",&lt;BR /&gt;"subtype": "Retail",&lt;BR /&gt;"name": "CCCCC",&lt;BR /&gt;"resourceCharacteristic": [&lt;BR /&gt;{&lt;BR /&gt;"propname": "aaa",&lt;BR /&gt;"value": "P_1655442"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"name": "latest",&lt;BR /&gt;"value": [&lt;BR /&gt;11,&lt;BR /&gt;200,&lt;BR /&gt;300,&lt;BR /&gt;16,&lt;BR /&gt;2,&lt;BR /&gt;3&lt;BR /&gt;]&lt;BR /&gt;}]&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To have an output like&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"records" : [ {&lt;BR /&gt;"timeStamp" : "1681441547144",&lt;BR /&gt;"activityId" : "5142917973836294867",&lt;BR /&gt;"drniId" : "261968731599587823",&lt;BR /&gt;"type" : "Order",&lt;BR /&gt;"subtype" : "Retail",&lt;BR /&gt;"name" : "CCCCC",&lt;BR /&gt;"propname" : "aaa",&lt;BR /&gt;"value" : "P_1655442"&lt;BR /&gt;&lt;BR /&gt;}, {&lt;BR /&gt;"timeStamp" : "1681441547144",&lt;BR /&gt;"activityId" : "5142917973836294867",&lt;BR /&gt;"drniId" : "261968731599587823",&lt;BR /&gt;"type" : "Order",&lt;BR /&gt;"subtype" : "Retail",&lt;BR /&gt;"name" : "CCCCC",&lt;BR /&gt;"propname" : "latest",&lt;BR /&gt;"value" : "11,200,300,16,2,3"&lt;BR /&gt;} ]&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically copying all the top header and resource into to new by flattening it. Any help appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 15:17:39 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Jolt-transformation-Array-to-Flatten/m-p/369487#M240498</guid>
      <dc:creator>Althotta</dc:creator>
      <dc:date>2023-04-26T15:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: Jolt transformation Array to  Flatten</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Jolt-transformation-Array-to-Flatten/m-p/369520#M240503</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Try the following spec:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[
  {
    // This is to remove the @ character from @type property because I could not
    // figure out how to make it work in the second shift using escape character '\'
    "operation": "shift",
    "spec": {
      "header": "&amp;amp;",
      "resource": {
        "\\@type": "resource.type",
        "*": "resource.&amp;amp;"
      }
    }
  },
  {
    "operation": "shift",
    "spec": {
      "resource": {
        "resourceCharacteristic": {
          "*": {
            "name": "records[&amp;amp;1].propname",
            "*": "records[&amp;amp;1].&amp;amp;",
            "@(2,name)": "records[&amp;amp;1].name",
            "@(2,type)": "records[&amp;amp;1].type",
            "@(2,subtype)": "records[&amp;amp;1].subtype",
            "@(2,drniId)": "records[&amp;amp;1].drniId",
            "@(3,header.activityId)": "records[&amp;amp;1].activityId",
            "@(3,header.timeStamp)": "records[&amp;amp;1].timeStamp"
          }
        }
      }
    }
  },
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "records": {
        "*": {
          "value": "=join(',', @(1,value))"
        }
      }
    }
  }
]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If that helps please accept solution.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 17:58:29 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Jolt-transformation-Array-to-Flatten/m-p/369520#M240503</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2023-04-26T17:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: Jolt transformation Array to  Flatten</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Jolt-transformation-Array-to-Flatten/m-p/369754#M240554</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;&amp;nbsp;.It worked. In the same way how do i get an simillar output for "resourceRelationshipCharacteristic" . i tried few option but not getting the desirable output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"header": {&lt;BR /&gt;"version": "1.0",&lt;BR /&gt;"timeStamp": "1681441547144",&lt;BR /&gt;"activityId": "5142917973836294867",&lt;BR /&gt;"action": "modify"&lt;BR /&gt;},&lt;BR /&gt;"resource": {&lt;BR /&gt;"drniId": "261968731599587823",&lt;BR /&gt;"@type": "VVVVV",&lt;BR /&gt;"subtype": "BBBBBB",&lt;BR /&gt;"name": "VVVVVVV",&lt;BR /&gt;"resourceCharacteristic": [&lt;BR /&gt;{&lt;BR /&gt;"name": "matchingkey",&lt;BR /&gt;"value": "CCCCC",&lt;BR /&gt;"@type": "string"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"resourceRelationship": [&lt;BR /&gt;{&lt;BR /&gt;"drniId": "261968731599587635",&lt;BR /&gt;"@type": "CCCCCC",&lt;BR /&gt;"subtype": "OTU4",&lt;BR /&gt;"name": "BBBBBB",&lt;BR /&gt;"relationDrniId": "5143209344417655493",&lt;BR /&gt;"resourceRelationshipCharacteristic": [&lt;BR /&gt;{&lt;BR /&gt;"name": "p3Latest",&lt;BR /&gt;"value": true,&lt;BR /&gt;"@type": "boolean"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"name": "isNotInRoute",&lt;BR /&gt;"value": "N",&lt;BR /&gt;"@type": "string"&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"drniId": "261988866406271344",&lt;BR /&gt;"@type": "BVDFDFS",&lt;BR /&gt;"subtype": "VDFDG",&lt;BR /&gt;"name": "ABCC",&lt;BR /&gt;"relationDrniId": "5143209344417655494",&lt;BR /&gt;"resourceRelationshipCharacteristic": [&lt;BR /&gt;{&lt;BR /&gt;"name": "p3Latest",&lt;BR /&gt;"value": true,&lt;BR /&gt;"@type": "boolean"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"name": "isNotInRoute",&lt;BR /&gt;"value": "N",&lt;BR /&gt;"@type": "string"&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2023 03:10:24 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Jolt-transformation-Array-to-Flatten/m-p/369754#M240554</guid>
      <dc:creator>Althotta</dc:creator>
      <dc:date>2023-05-01T03:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Jolt transformation Array to  Flatten</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Jolt-transformation-Array-to-Flatten/m-p/369781#M240560</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;Can you provide the expected json output? The json you provided seems complex and nested. I'm not sure what exactly you are expecting.&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2023 13:30:31 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Jolt-transformation-Array-to-Flatten/m-p/369781#M240560</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2023-05-01T13:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Jolt transformation Array to  Flatten</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Jolt-transformation-Array-to-Flatten/m-p/369802#M240562</link>
      <description>&lt;P&gt;Basically inhertied properties of header and resource inside&amp;nbsp;&lt;SPAN&gt;resourceRelationshipCharacteristic&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"records" : [ {&lt;BR /&gt;"relationDrniId" : "5143209344417655493",&lt;BR /&gt;"timeStamp" : "1681441547144",&lt;BR /&gt;"activityId" : "5142917973836294867",&lt;BR /&gt;"action" : "modify",&lt;BR /&gt;"name": "p3Latest",&lt;BR /&gt;"value": true,&lt;BR /&gt;"@type": "boolean"&lt;BR /&gt;&lt;BR /&gt;},&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;"relationDrniId" : "5143209344417655493",&lt;BR /&gt;"timeStamp" : "1681441547144",&lt;BR /&gt;"activityId" : "5142917973836294867",&lt;BR /&gt;"action" : "modify",&lt;BR /&gt;"name": "isNotInRoute",&lt;BR /&gt;"value": "N",&lt;BR /&gt;"@type": "string"&lt;BR /&gt;&lt;BR /&gt;} ,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;"relationDrniId" : "5143209344417655494",&lt;BR /&gt;"timeStamp" : "1681441547144",&lt;BR /&gt;"activityId" : "5142917973836294867",&lt;BR /&gt;"action" : "modify",&lt;BR /&gt;"name": "p3Latest",&lt;BR /&gt;"value": true,&lt;BR /&gt;"@type": "boolean"&lt;BR /&gt;&lt;BR /&gt;} ,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;"relationDrniId" : "5143209344417655494",&lt;BR /&gt;"timeStamp" : "1681441547144",&lt;BR /&gt;"activityId" : "5142917973836294867",&lt;BR /&gt;"action" : "modify",&lt;BR /&gt;"name": "isNotInRoute",&lt;BR /&gt;"value": "N",&lt;BR /&gt;"@type": "string"&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>Tue, 02 May 2023 00:08:24 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Jolt-transformation-Array-to-Flatten/m-p/369802#M240562</guid>
      <dc:creator>Althotta</dc:creator>
      <dc:date>2023-05-02T00:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: Jolt transformation Array to  Flatten</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Jolt-transformation-Array-to-Flatten/m-p/369859#M240573</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;This one was a little trickier from the first post, but it seems that there is nothing that you cant do with Jolt &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; . Please try the following spec:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[
  {
    // combine all resourceRelationshipCharacteristic under one group
    // and assign each element under the group unique key depending on
    // its index location starting from first array under resourceRelationship (&amp;amp;3) and
    // and ending with nested array resourceRelationshipCharacteristic ($1) so
    // each element will have unique name 00,01,10,11...
    "operation": "shift",
    "spec": {
      "resource": {
        "resourceRelationship": {
          "*": {
            "resourceRelationshipCharacteristic": {
              "*": {
                "@(6,header.action)": "&amp;amp;3&amp;amp;1.action",
                "@(6,header.timeStamp)": "&amp;amp;3&amp;amp;1.timeStamp",
                "@(2,relationDrniId)": "&amp;amp;3&amp;amp;1.relationDrniId",
                "*": "&amp;amp;3&amp;amp;1.&amp;amp;"
              }
            }
          }
        }
      }
    }
  },
  {
    // bucket each element (00,01,10,11) value into new Array records
    "operation": "shift",
    "spec": {
      "*": "records.[#1]"
    }
  }
]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;P&gt;I wonder if there is better\cleaner way &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/11191"&gt;@araujo&lt;/a&gt;&amp;nbsp; &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/103151"&gt;@cotopaul&lt;/a&gt; &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/95503"&gt;@steven-matison&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 16:48:43 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Jolt-transformation-Array-to-Flatten/m-p/369859#M240573</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2023-05-02T16:48:43Z</dc:date>
    </item>
    <item>
      <title>Re: Jolt transformation Array to  Flatten</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Jolt-transformation-Array-to-Flatten/m-p/369867#M240579</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;&amp;nbsp;You are a genius. I was caught with the duplicate index array and couldn't resolve.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2023 02:11:45 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Jolt-transformation-Array-to-Flatten/m-p/369867#M240579</guid>
      <dc:creator>Althotta</dc:creator>
      <dc:date>2023-05-03T02:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: Jolt transformation Array to  Flatten</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Jolt-transformation-Array-to-Flatten/m-p/370253#M240667</link>
      <description>&lt;P&gt;I have used the below spec for moving some of the resource characterstic to top level but iam getting null values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;[&lt;BR /&gt;{&lt;BR /&gt;"operation": "shift",&lt;BR /&gt;"spec": {&lt;BR /&gt;"header": {&lt;BR /&gt;"timeStamp": "records.inv_activity_ts",&lt;BR /&gt;"activityId": "records.inv_activity_id",&lt;BR /&gt;"action": "records.action"&lt;BR /&gt;},&lt;BR /&gt;"resource": {&lt;BR /&gt;"drniId": "records.inv_id",&lt;BR /&gt;"subtype": "records.inv_subtype",&lt;BR /&gt;"name": "records.inv_name",&lt;BR /&gt;"resourceCharacteristic": {&lt;BR /&gt;"*": {&lt;BR /&gt;"name": {&lt;BR /&gt;"&lt;SPAN&gt;matchingkey&lt;/SPAN&gt;": "records.&lt;SPAN&gt;matchingkey&lt;/SPAN&gt;-value",&lt;BR /&gt;"status": "records.status-value"&lt;BR /&gt;},&lt;BR /&gt;"value": {&lt;BR /&gt;"&lt;SPAN&gt;matchingkey&lt;/SPAN&gt;": "records.&lt;SPAN&gt;matchingkey&lt;/SPAN&gt;-value",&lt;BR /&gt;"status": "records.status-value"&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output iam getting&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"records" : {&lt;BR /&gt;"inv_activity_ts" : "1670484663189",&lt;BR /&gt;"inv_activity_id" : "256388257993155783",&lt;BR /&gt;"action" : "create",&lt;BR /&gt;"inv_id" : "256383859946641699",&lt;BR /&gt;"inv_subtype" : "Backplane Connection",&lt;BR /&gt;"inv_name" : "Backplane Connection",&lt;BR /&gt;"&lt;SPAN&gt;matchingkey&lt;/SPAN&gt;-value" : null,&lt;BR /&gt;"status-value" : null&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is mistake iam making?.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2023 12:29:59 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Jolt-transformation-Array-to-Flatten/m-p/370253#M240667</guid>
      <dc:creator>Althotta</dc:creator>
      <dc:date>2023-05-08T12:29:59Z</dc:date>
    </item>
  </channel>
</rss>

