<?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 Jolt to transform muliple values in an array in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Jolt-to-transform-muliple-values-in-an-array/m-p/379309#M243827</link>
    <description>&lt;P&gt;I am trying to transform a json using jolt where i am moving the array inside&amp;nbsp;&lt;STRONG&gt;serviceCharacteristic to&amp;nbsp;&lt;/STRONG&gt;outside of service {}, eventually i plan to move to respective positions&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
  "serviceOrderItem": [
    {
      "action": "modify",
      "id": "0965f63b-db26-4397-b222-190a891838f0",
      "service": {
        "href": "serviceInventory/v4/service/adaptiveNetworkSite/1b9a3fae-f50b-4310-887d-60988f8d5645",
        "id": "adaptiveNetworkSite",
        "serviceCharacteristic": [
          {
            "name": "modifyPath",
            "value": [
              {
                "op": "add",
                "path": "$.supportingService",
                "value": {}
              },
              {
                "op": "sub",
                "path": "$.supportingService",
                "value": {}
              }
            ]
          }
        ]
      }
    },
    {
      "action": "create",
      "id": "0965f63b-db26-4397-b222-190a891838f0",
      "service": {
        "href": "serviceInventory/v4/service/adaptiveNetworkSite/1b9a3fae-f50b-4310-887d-60988f8d5645",
        "id": "adaptiveNetworkSite",
        "serviceCharacteristic": [
          {
            "name": "modifyPath",
            "value": [
              {
                "op": "abcd",
                "path": "$.supportingService",
                "value": {
                  "state": "active"
                }
              },
              {
                "op": "efgh",
                "path": "$.supportingService",
                "value": {
                  "state": "active"
                }
              }
            ]
          }
        ]
      }
    }
  ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;desired output is&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
  "serviceOrderItem": [
    {
      "action": "modify",
      "id": "0965f63b-db26-4397-b222-190a891838f0",
      "service": {
        "href": "serviceInventory/v4/service/adaptiveNetworkSite/1b9a3fae-f50b-4310-887d-60988f8d5645",
        "id": "adaptiveNetworkSite"
		}
        "modifyPath": [
          
              {
                "op": "add",
                "path": "$.supportingService",
                "value": {}
              },
              {
                "op": "sub",
                "path": "$.supportingService",
                "value": {}
              }
            ] 
    },
    {
      "action": "create",
      "id": "0965f63b-db26-4397-b222-190a891838f0",
      "service": {
        "href": "serviceInventory/v4/service/adaptiveNetworkSite/1b9a3fae-f50b-4310-887d-60988f8d5645",
        "id": "adaptiveNetworkSite"
		}
        "modifyPath": [          
              {
                "op": "abcd",
                "path": "$.supportingService",
                "value": {
                  "state": "active"
                }
              },
              {
                "op": "efgh",
                "path": "$.supportingService",
                "value": {
                  "state": "active"
                }
              }
            ]          
        
      }
    }
  ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my Jolt is working only when there is single array in&amp;nbsp;modifyPath&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;[{
  "operation": "shift",
  "spec": {
    "*": "&amp;amp;",
    "serviceOrderItem": {
      "*": {
        "*": "serviceOrderItem[&amp;amp;1].&amp;amp;",
        "service": {
          "*": "serviceOrderItem[&amp;amp;2].service.&amp;amp;",
          "serviceCharacteristic": {
            "*": {
              "value": "@(1,name)"
            }
          }
        }
      }
    }
  }
}, {
  "operation": "shift",
  "spec": {
    "*": "&amp;amp;",
    "modifyPath": {
      "@(1,modifyPath)": "serviceOrderItem[0].modifyPath"
    },
    "supportingService": {
      "@(1,supportingService)": "serviceOrderItem[0].service.supportingService"
    }
  }
}]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when multiple array is given it shuffles the array,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;  "serviceOrderItem" : [ {
    "action" : "modify",
    "id" : "0965f63b-db26-4397-b222-190a891838f0",
    "modifyPath" : [ {
      "op" : "add",
      "path" : "$.supportingService",
      "value" : { }
    }, {
      "op" : "sub",
      "path" : "$.supportingService",
      "value" : { }
    }, [ {
      "op" : "abcd",
      "path" : "$.supportingService",
      "value" : {
        "state" : "active"
      }
    }, {
      "op" : "efgh",
      "path" : "$.supportingService",
      "value" : {
        "state" : "active"
      }
    } ] ],
    "service" : {
      "href" : "serviceInventory/v4/service/adaptiveNetworkSite/1b9a3fae-f50b-4310-887d-60988f8d5645",
      "id" : "adaptiveNetworkSite"
    }
  }, {
    "action" : "create",
    "id" : "0965f63b-db26-4397-b222-190a891838f0",
    "service" : {
      "href" : "serviceInventory/v4/service/adaptiveNetworkSite/1b9a3fae-f50b-4310-887d-60988f8d5645",
      "id" : "adaptiveNetworkSite"
    }
  } ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please advise , thank you for you time&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Nov 2023 13:58:29 GMT</pubDate>
    <dc:creator>scoutjohn</dc:creator>
    <dc:date>2023-11-21T13:58:29Z</dc:date>
    <item>
      <title>Jolt to transform muliple values in an array</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Jolt-to-transform-muliple-values-in-an-array/m-p/379309#M243827</link>
      <description>&lt;P&gt;I am trying to transform a json using jolt where i am moving the array inside&amp;nbsp;&lt;STRONG&gt;serviceCharacteristic to&amp;nbsp;&lt;/STRONG&gt;outside of service {}, eventually i plan to move to respective positions&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
  "serviceOrderItem": [
    {
      "action": "modify",
      "id": "0965f63b-db26-4397-b222-190a891838f0",
      "service": {
        "href": "serviceInventory/v4/service/adaptiveNetworkSite/1b9a3fae-f50b-4310-887d-60988f8d5645",
        "id": "adaptiveNetworkSite",
        "serviceCharacteristic": [
          {
            "name": "modifyPath",
            "value": [
              {
                "op": "add",
                "path": "$.supportingService",
                "value": {}
              },
              {
                "op": "sub",
                "path": "$.supportingService",
                "value": {}
              }
            ]
          }
        ]
      }
    },
    {
      "action": "create",
      "id": "0965f63b-db26-4397-b222-190a891838f0",
      "service": {
        "href": "serviceInventory/v4/service/adaptiveNetworkSite/1b9a3fae-f50b-4310-887d-60988f8d5645",
        "id": "adaptiveNetworkSite",
        "serviceCharacteristic": [
          {
            "name": "modifyPath",
            "value": [
              {
                "op": "abcd",
                "path": "$.supportingService",
                "value": {
                  "state": "active"
                }
              },
              {
                "op": "efgh",
                "path": "$.supportingService",
                "value": {
                  "state": "active"
                }
              }
            ]
          }
        ]
      }
    }
  ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;desired output is&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
  "serviceOrderItem": [
    {
      "action": "modify",
      "id": "0965f63b-db26-4397-b222-190a891838f0",
      "service": {
        "href": "serviceInventory/v4/service/adaptiveNetworkSite/1b9a3fae-f50b-4310-887d-60988f8d5645",
        "id": "adaptiveNetworkSite"
		}
        "modifyPath": [
          
              {
                "op": "add",
                "path": "$.supportingService",
                "value": {}
              },
              {
                "op": "sub",
                "path": "$.supportingService",
                "value": {}
              }
            ] 
    },
    {
      "action": "create",
      "id": "0965f63b-db26-4397-b222-190a891838f0",
      "service": {
        "href": "serviceInventory/v4/service/adaptiveNetworkSite/1b9a3fae-f50b-4310-887d-60988f8d5645",
        "id": "adaptiveNetworkSite"
		}
        "modifyPath": [          
              {
                "op": "abcd",
                "path": "$.supportingService",
                "value": {
                  "state": "active"
                }
              },
              {
                "op": "efgh",
                "path": "$.supportingService",
                "value": {
                  "state": "active"
                }
              }
            ]          
        
      }
    }
  ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my Jolt is working only when there is single array in&amp;nbsp;modifyPath&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;[{
  "operation": "shift",
  "spec": {
    "*": "&amp;amp;",
    "serviceOrderItem": {
      "*": {
        "*": "serviceOrderItem[&amp;amp;1].&amp;amp;",
        "service": {
          "*": "serviceOrderItem[&amp;amp;2].service.&amp;amp;",
          "serviceCharacteristic": {
            "*": {
              "value": "@(1,name)"
            }
          }
        }
      }
    }
  }
}, {
  "operation": "shift",
  "spec": {
    "*": "&amp;amp;",
    "modifyPath": {
      "@(1,modifyPath)": "serviceOrderItem[0].modifyPath"
    },
    "supportingService": {
      "@(1,supportingService)": "serviceOrderItem[0].service.supportingService"
    }
  }
}]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when multiple array is given it shuffles the array,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;  "serviceOrderItem" : [ {
    "action" : "modify",
    "id" : "0965f63b-db26-4397-b222-190a891838f0",
    "modifyPath" : [ {
      "op" : "add",
      "path" : "$.supportingService",
      "value" : { }
    }, {
      "op" : "sub",
      "path" : "$.supportingService",
      "value" : { }
    }, [ {
      "op" : "abcd",
      "path" : "$.supportingService",
      "value" : {
        "state" : "active"
      }
    }, {
      "op" : "efgh",
      "path" : "$.supportingService",
      "value" : {
        "state" : "active"
      }
    } ] ],
    "service" : {
      "href" : "serviceInventory/v4/service/adaptiveNetworkSite/1b9a3fae-f50b-4310-887d-60988f8d5645",
      "id" : "adaptiveNetworkSite"
    }
  }, {
    "action" : "create",
    "id" : "0965f63b-db26-4397-b222-190a891838f0",
    "service" : {
      "href" : "serviceInventory/v4/service/adaptiveNetworkSite/1b9a3fae-f50b-4310-887d-60988f8d5645",
      "id" : "adaptiveNetworkSite"
    }
  } ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please advise , thank you for you time&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2023 13:58:29 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Jolt-to-transform-muliple-values-in-an-array/m-p/379309#M243827</guid>
      <dc:creator>scoutjohn</dc:creator>
      <dc:date>2023-11-21T13:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: Jolt to transform muliple values in an array</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Jolt-to-transform-muliple-values-in-an-array/m-p/379312#M243830</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/97154"&gt;@scoutjohn&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;I think you are over complicating the spec unless Im missing something. You can do the transformation in one shift spec if you are just looking to move the "&lt;STRONG&gt;serviceCharacteristic&lt;/STRONG&gt;"&amp;nbsp; elements to the upper level where the service object remain as is, and value of&amp;nbsp; "name"&amp;nbsp; is used as parent to the "value" array.&lt;/P&gt;&lt;P&gt;In this case you can use the following spec:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[
  {
    "operation": "shift",
    "spec": {
      "serviceOrderItem": {
        "*": {
          "*": "serviceOrderItem[&amp;amp;1].&amp;amp;",
          "service": {
            "href": "serviceOrderItem[&amp;amp;2].service.href",
            "id": "serviceOrderItem[&amp;amp;2].service.id",
            "serviceCharacteristic": {
              "*": {
                "value": "serviceOrderItem[&amp;amp;4].@(1,name)"
              }
            }
          }
        }
      }
    }
  }
]&lt;/LI-CODE&gt;&lt;P&gt;If that helps please &lt;STRONG&gt;accept&lt;/STRONG&gt; solution.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2023 14:32:30 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Jolt-to-transform-muliple-values-in-an-array/m-p/379312#M243830</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2023-11-21T14:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: Jolt to transform muliple values in an array</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Jolt-to-transform-muliple-values-in-an-array/m-p/379333#M243835</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 you, that solved it&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2023 16:45:53 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Jolt-to-transform-muliple-values-in-an-array/m-p/379333#M243835</guid>
      <dc:creator>scoutjohn</dc:creator>
      <dc:date>2023-11-21T16:45:53Z</dc:date>
    </item>
  </channel>
</rss>

