<?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 Stuck with this JOLT  Tranformation in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Stuck-with-this-JOLT-Tranformation/m-p/371591#M241017</link>
    <description>&lt;P&gt;Hi Community,&lt;/P&gt;&lt;P&gt;hope someone can help me to build this transform:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Input:&lt;/P&gt;&lt;LI-CODE lang="php"&gt;{
"Orders": [{
"Headers": {
"UniqShipment": "0"
},
"Goods": [{
"GoodsTypeID": 3,
"GoodsTypeName": "ALTRI MOBILI LEGNO",
"GoodsDetails": [{
"Packs": 1

}, {
"Packs": 1
}, {
"Packs": 1
}]
}],
"References": [{
"TypeReference": "DT",
"ValueReference": "006611",
"DateReference": "2023-04-14"
}, {
"TypeReference": "CM",
"ValueReference": "JOHN"
}, {
"TypeReference": "OC",
"ValueReference": "V1250-0010"
}, {
"TypeReference": "RG",
"ValueReference": "TRCA_CATR726240_CA_006611_14_04_2023.json"
}]

}]
}&lt;/LI-CODE&gt;&lt;P&gt;My Desired Output:&lt;/P&gt;&lt;LI-CODE lang="php"&gt;{
	"header": {
		"UniqShipment": "0"
	},
	"rows": {
		"GoodsTypeName": ["ALTRI MOBILI LEGNO", "ALTRI MOBILI LEGNO", "ALTRI MOBILI LEGNO"],
		"Packs": [1, 1, 1],
		"ValueReference": ["V1250-0010", "V1250-0010", "V1250-0010"]
	}
}&lt;/LI-CODE&gt;&lt;P&gt;My Transformation so far:&lt;/P&gt;&lt;LI-CODE lang="php"&gt;[
  {
    "operation": "shift",
    "spec": {
      "Orders": {
        "*": {
          "Headers": "header",
          "Goods": {
            "*": {
              "GoodsDetails": {
                "*": {
                  "@(2,GoodsTypeName)": "rows.GoodsTypeName",
                  "Packs": "rows.Packs"
                }
              }
            }
          }
        }
      }
    }
  }
]&lt;/LI-CODE&gt;&lt;P&gt;Which Produce the following result:&lt;/P&gt;&lt;LI-CODE lang="php"&gt;{
  "header" : {
    "UniqShipment" : "0"
  },
  "rows" : {
    "GoodsTypeName" : [ "ALTRI MOBILI LEGNO", "ALTRI MOBILI LEGNO", "ALTRI MOBILI LEGNO" ],
    "Packs" : [ 1, 1, 1 ]
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Now i need to make the last part:&lt;/P&gt;&lt;P&gt;Based on the value of TypeReference which has to be "OC" then add the list of ValueReference per each element of "rows array" like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;{
	"header": {
		"UniqShipment": "0"
	},
	"rows": {
		"GoodsTypeName": ["ALTRI MOBILI LEGNO", "ALTRI MOBILI LEGNO", "ALTRI MOBILI LEGNO"],
		"Packs": [1, 1, 1],
		"TypeReference": ["V1250-0010", "V1250-0010", "V1250-0010"]
	}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many Thanks for your help, appreciate!&lt;/P&gt;</description>
    <pubDate>Fri, 26 May 2023 07:13:53 GMT</pubDate>
    <dc:creator>Ray82</dc:creator>
    <dc:date>2023-05-26T07:13:53Z</dc:date>
    <item>
      <title>Stuck with this JOLT  Tranformation</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Stuck-with-this-JOLT-Tranformation/m-p/371591#M241017</link>
      <description>&lt;P&gt;Hi Community,&lt;/P&gt;&lt;P&gt;hope someone can help me to build this transform:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Input:&lt;/P&gt;&lt;LI-CODE lang="php"&gt;{
"Orders": [{
"Headers": {
"UniqShipment": "0"
},
"Goods": [{
"GoodsTypeID": 3,
"GoodsTypeName": "ALTRI MOBILI LEGNO",
"GoodsDetails": [{
"Packs": 1

}, {
"Packs": 1
}, {
"Packs": 1
}]
}],
"References": [{
"TypeReference": "DT",
"ValueReference": "006611",
"DateReference": "2023-04-14"
}, {
"TypeReference": "CM",
"ValueReference": "JOHN"
}, {
"TypeReference": "OC",
"ValueReference": "V1250-0010"
}, {
"TypeReference": "RG",
"ValueReference": "TRCA_CATR726240_CA_006611_14_04_2023.json"
}]

}]
}&lt;/LI-CODE&gt;&lt;P&gt;My Desired Output:&lt;/P&gt;&lt;LI-CODE lang="php"&gt;{
	"header": {
		"UniqShipment": "0"
	},
	"rows": {
		"GoodsTypeName": ["ALTRI MOBILI LEGNO", "ALTRI MOBILI LEGNO", "ALTRI MOBILI LEGNO"],
		"Packs": [1, 1, 1],
		"ValueReference": ["V1250-0010", "V1250-0010", "V1250-0010"]
	}
}&lt;/LI-CODE&gt;&lt;P&gt;My Transformation so far:&lt;/P&gt;&lt;LI-CODE lang="php"&gt;[
  {
    "operation": "shift",
    "spec": {
      "Orders": {
        "*": {
          "Headers": "header",
          "Goods": {
            "*": {
              "GoodsDetails": {
                "*": {
                  "@(2,GoodsTypeName)": "rows.GoodsTypeName",
                  "Packs": "rows.Packs"
                }
              }
            }
          }
        }
      }
    }
  }
]&lt;/LI-CODE&gt;&lt;P&gt;Which Produce the following result:&lt;/P&gt;&lt;LI-CODE lang="php"&gt;{
  "header" : {
    "UniqShipment" : "0"
  },
  "rows" : {
    "GoodsTypeName" : [ "ALTRI MOBILI LEGNO", "ALTRI MOBILI LEGNO", "ALTRI MOBILI LEGNO" ],
    "Packs" : [ 1, 1, 1 ]
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Now i need to make the last part:&lt;/P&gt;&lt;P&gt;Based on the value of TypeReference which has to be "OC" then add the list of ValueReference per each element of "rows array" like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;{
	"header": {
		"UniqShipment": "0"
	},
	"rows": {
		"GoodsTypeName": ["ALTRI MOBILI LEGNO", "ALTRI MOBILI LEGNO", "ALTRI MOBILI LEGNO"],
		"Packs": [1, 1, 1],
		"TypeReference": ["V1250-0010", "V1250-0010", "V1250-0010"]
	}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many Thanks for your help, appreciate!&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2023 07:13:53 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Stuck-with-this-JOLT-Tranformation/m-p/371591#M241017</guid>
      <dc:creator>Ray82</dc:creator>
      <dc:date>2023-05-26T07:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: Stuck with this JOLT  Tranformation</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Stuck-with-this-JOLT-Tranformation/m-p/371601#M241021</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I think you can achieve this in two shift transformation as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[
  {
    // 1st transformation is basically to isolate 
    // "OC" value reference into Orders.ValueReference
    "operation": "shift",
    "spec": {
      "Orders": {
        "*": {
          "Headers": "Orders[#2].&amp;amp;",
          "Goods": "Orders[#2].&amp;amp;",
          "References": {
            "*": {
              "TypeReference": {
                "OC": {
                  "@(2,ValueReference)": "Orders[#2].ValueReference"
                }
              }
            }
          }
        }
      }
    }
  },
  //2ed Transformation is the same as you had except for
  //fetching the isolated ValueReference above
  //into its own Array based on the GoodsDetails array
  {
    "operation": "shift",
    "spec": {
      "Orders": {
        "*": {
          "Headers": "header",
          "Goods": {
            "*": {
              "GoodsDetails": {
                "*": {
                  "@(2,GoodsTypeName)": "rows.GoodsTypeName",
                  "Packs": "rows.Packs",
                  "@(4,ValueReference)": "rows.ValueReference"
                }
              }
            }
          }
        }
      }
    }
  }

]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the helps please accept solution.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2023 14:17:41 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Stuck-with-this-JOLT-Tranformation/m-p/371601#M241021</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2023-05-26T14:17:41Z</dc:date>
    </item>
  </channel>
</rss>

