<?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- rearrange elements in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Jolt-rearrange-elements/m-p/368598#M240217</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You have not specified the desired output, but would the following give you what you are looking for:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[
  {
    "operation": "shift",
    "spec": {
      "Details": {
        "*": {
          "*": "Details[#2].&amp;amp;"
        }
      },
      "*": "outer[].&amp;amp;"
    }
  },
  {
    "operation": "shift",
    "spec": {
      "Details": "Details",
      "outer": {
        "*": {
          "*": "Details[&amp;amp;1].&amp;amp;"
        }
      }
    }
  }
]&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;</description>
    <pubDate>Sun, 16 Apr 2023 15:19:25 GMT</pubDate>
    <dc:creator>SAMSAL</dc:creator>
    <dc:date>2023-04-16T15:19:25Z</dc:date>
    <item>
      <title>Jolt- rearrange elements</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Jolt-rearrange-elements/m-p/368592#M240212</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;I am using jolt to change the structure of a payload to another form, and it must be dynamic, especially the top level elements "test" which can be multiple. I have tried but not getting it. I would appreciate your kind help.&lt;/P&gt;&lt;P&gt;Here is my input json:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
  "test1": "test output",
  "test2": "test output",
  "Details": {
    "0": {
      "id": "first",
      "name": "the first one"
    },
    "1": {
      "id": "second",
      "name": "the second one"
    }
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and my output json is :&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
  "Details" : [ {
    "test1" : "test output",
    "test2" : "test output",
    "id" : "first",
    "name" : "the first one"
  }, {
    "test1" : "test output",
    "test2" : "test output",
    "id" : "second",
    "name" : "the second one"
  } ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my current jolt spec is:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;[
  {
    "operation": "shift",
    "spec": {
      "Details": "Details",
      "*": "outer.&amp;amp;"
    }
  },
  {
    "operation": "shift",
    "spec": {
      "Details": {
        "*": {
          "*": "Details[&amp;amp;1].&amp;amp;",
          "@(2,outer)": "Details[&amp;amp;1].outer"
        }
      }
    }
  },
  {
    "operation": "shift",
    "spec": {
      "Details": {
        "*": {
          "outer": {
            "*": "Details[&amp;amp;2].&amp;amp;"
          },
          "*": "Details[&amp;amp;1].&amp;amp;"
        }
      }
    }
  }
]&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;But I am not getting the desired output json as above.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2026 07:16:13 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Jolt-rearrange-elements/m-p/368592#M240212</guid>
      <dc:creator>rafy</dc:creator>
      <dc:date>2026-04-21T07:16:13Z</dc:date>
    </item>
    <item>
      <title>Re: Jolt- rearrange elements</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Jolt-rearrange-elements/m-p/368598#M240217</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You have not specified the desired output, but would the following give you what you are looking for:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[
  {
    "operation": "shift",
    "spec": {
      "Details": {
        "*": {
          "*": "Details[#2].&amp;amp;"
        }
      },
      "*": "outer[].&amp;amp;"
    }
  },
  {
    "operation": "shift",
    "spec": {
      "Details": "Details",
      "outer": {
        "*": {
          "*": "Details[&amp;amp;1].&amp;amp;"
        }
      }
    }
  }
]&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;</description>
      <pubDate>Sun, 16 Apr 2023 15:19:25 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Jolt-rearrange-elements/m-p/368598#M240217</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2023-04-16T15:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: Jolt- rearrange elements</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Jolt-rearrange-elements/m-p/368599#M240218</link>
      <description>&lt;P&gt;Thank you sir &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;Actually the desired output is&lt;/P&gt;&lt;PRE&gt;{
  "Details" : {&lt;BR /&gt;   "0":{
    "test1" : "test output",
    "test2" : "test output",
    "id" : "first",
    "name" : "the first one"
  }}, &lt;BR /&gt;    "Details":{&lt;BR /&gt;    "1":{
    "test1" : "test output",
    "test2" : "test output",
    "id" : "second",
    "name" : "the second one"
  }}&lt;BR /&gt;
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Apr 2023 15:51:24 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Jolt-rearrange-elements/m-p/368599#M240218</guid>
      <dc:creator>rafy</dc:creator>
      <dc:date>2023-04-16T15:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: Jolt- rearrange elements</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Jolt-rearrange-elements/m-p/368601#M240220</link>
      <description>&lt;P&gt;Im not sure what you specified is makes sense&amp;nbsp; because you would have two keys with the same name "Details" but different values. I assume what you want is this:&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;{
	"Details": {
		"0": {
			"test1": "test output",
			"test2": "test output",
			"id": "first",
			"name": "the first one"
		},
		"1": {
			"test1": "test output",
			"test2": "test output",
			"id": "second",
			"name": "the second one"
		}
	}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this case the spec would be like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[
  {
    //package all test fields into an outer object
    "operation": "shift",
    "spec": {
      "test*": "outer.&amp;amp;",
      "Details": "Details"
    }
   },
  {
    // Insert each outer object into Details element 0,1,..
    "operation": "shift",
    "spec": {
      "Details": {
        "*": {
          "*": "Details.&amp;amp;1.&amp;amp;",
          "@(3,outer)": "Details.&amp;amp;1.outer"
        }
      }
    }
   },
  {
    //Bucket each outer object (test1, test2...) into each details element
    "operation": "shift",
    "spec": {
      "Details": {
        "*": {
          "*": "Details.&amp;amp;1.&amp;amp;",
          "outer": {
            "*": {
              "@": "Details.&amp;amp;3.&amp;amp;"
            }
          }
        }
      }
    }
   }
]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure if this is the best way, if someone knows a better way please&amp;nbsp; provide your suggestion.&lt;/P&gt;&lt;P&gt;If that answers your question 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;</description>
      <pubDate>Sun, 16 Apr 2023 18:50:01 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Jolt-rearrange-elements/m-p/368601#M240220</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2023-04-16T18:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: Jolt- rearrange elements</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Jolt-rearrange-elements/m-p/368602#M240221</link>
      <description>&lt;P&gt;I am very grateful for your help so far sir&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;.&lt;/P&gt;&lt;P&gt;Actually, i made a silly mistake concerning that key duplication.&lt;/P&gt;&lt;P&gt;I wanted to have something of this nature, that is separate objects each with "Details" topmost level.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  "Details" : {
   "0":{
    "test1" : "test output",
    "test2" : "test output",
    "id" : "first",
    "name" : "the first one"
  }}, 
    "Details":{
    "1":{
    "test1" : "test output",
    "test2" : "test output",
    "id" : "second",
    "name" : "the second one"
  }}&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;</description>
      <pubDate>Sun, 16 Apr 2023 19:58:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Jolt-rearrange-elements/m-p/368602#M240221</guid>
      <dc:creator>rafy</dc:creator>
      <dc:date>2023-04-16T19:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: Jolt- rearrange elements</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Jolt-rearrange-elements/m-p/368719#M240242</link>
      <description>&lt;P&gt;Try the below spec. Again not sure if this is the most efficient way. You might need to rethink your strategy if you are dealing with a lot of data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[
  {
    //package all test fields into an outer object
    "operation": "shift",
    "spec": {
      "test*": "outer.&amp;amp;",
      "Details": "Details"
    }
   },
  {
    // Insert each outer object into Details element 0,1,..
    "operation": "shift",
    "spec": {
      "Details": {
        "*": {
          "*": "Details.&amp;amp;1.&amp;amp;",
          "@(3,outer)": "Details.&amp;amp;1.outer"
        }
      }
    }
   },
  {
    //Bucket each outer object (test1, test2...) into each details element
    "operation": "shift",
    "spec": {
      "Details": {
        "*": {
          "*": "Details.&amp;amp;1.&amp;amp;",
          "outer": {
            "*": {
              "@": "Details.&amp;amp;3.&amp;amp;"
            }
          }
        }
      }
    }
   },
  {
    //package details into seperate element under an Array 
    "operation": "shift",
    "spec": {
      "Details": {
        "*": "[#1].Details.&amp;amp;"
      }
    }
   }
  ]&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 17 Apr 2023 16:21:57 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Jolt-rearrange-elements/m-p/368719#M240242</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2023-04-17T16:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: Jolt- rearrange elements</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Jolt-rearrange-elements/m-p/368901#M240303</link>
      <description>&lt;P&gt;Thank you sir&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;I am very grateful, at the moment, your solution does the job.&lt;BR /&gt;Also, i would love to learn JoltTransformation from you.&lt;BR /&gt;Thanks once again.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 10:16:40 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Jolt-rearrange-elements/m-p/368901#M240303</guid>
      <dc:creator>rafy</dc:creator>
      <dc:date>2023-04-19T10:16:40Z</dc:date>
    </item>
  </channel>
</rss>

