title: Newbie: Transform json repetitions to Single Arrays and add Entry Inside
body: <p>I'm looking for some Jolt help.  I'm officially a newbie attempting to understand if Jolt will suffice for usage in our solution.  I can't seem to get the following output as I would expect.</p>
  
  <p>I was wondering if anyone could help me, and see if this template would be able to help out on our other needs for structures of the same fashion.  Also, if anyone has the best/better reading they suggest on Jolt, I'm happy to hear of that as well.</p>
  
  <p>In a nutshell, I'm trying to use JOLT to handle the following Needs:</p>
  
  <ol>
  <li>From a JSON input, if there are multiple repetitions of a structure, output these repetitions as an array of the independent json structures.  </li>
  <li>From the parent level, take a named match SetIDAL1 and place into the top created json structure, but not as part of the array, and as its own element.</li>
  </ol>
  
  <p>Here is an example of my input I need to transform:</p>
  
  <pre><code>  "AL1": {
      "0": {
        "AllergenCodeMnemonicDescription": {
          "1": {
            "Text": "ASPIRIN",
            "ID": "TEST1"
          },
          "2": {
            "Text": "TYLENOL",
            "ID": "TEST2"
          }
        },
        "SetIDAL1": "1"
      },
      "1": {
        "AllergenCodeMnemonicDescription": {
          "1": {
            "Text": "ADVIL"
          }
        },
        "SetIDAL1": "2"
      }
    }
  }
  </code></pre>
  
  <p>My current spec I'm using seems to get me pretty close. However, I can't get the arrays up a level in order to remove the 0:1, nor fix the fact that I want the SetIDAL1 value placed inside the newly created array object, instead it makes it's own array object.  I've played around with various other options that only lead me further away.    Any help for the solution and input/guidance, general "smart ways" to look at this issue would be appreciated.</p>
  
  <p>Unfortunately, I do not have a copy of previous work I tried, which would perform the matching on all groups and map them as expected.  I started moving toward matching each individual 0/1 object underneath my input in attempts to see if I could "bury" the SetIDAL properly, to no avail.  I really do not want to code for each level, but hoping there's a solution for the "problem at hand" that someone can assist me with. </p>
  
  <pre><code>[
    {
      "operation": "shift",
      "spec": {
        "AL1": {
          "0": {
            "AllergenCodeMnemonicDescription": {
              "@": "AL1.[].AllergenCodeMnemonicDescription.[]"
            },
            "SetIDAL1": "AL1.[].SetIDAL1"
          },
          "1": {
            "AllergenCodeMnemonicDescription": {
              "*": "AL1.[].AllergenCodeMnemonicDescription.[]"
            },
            "SetIDAL1": "AL1.[].SetIDAL1"
          }
        }
      }
    }
  
  ]
  </code></pre>
  
  <p>here is the output I am getting.  I assume potentially I need yet another shift after this, to bring the "1"/"2" levels "UP again" somehow.  But I can't seem to get the SetIDAL1 in the correct place as stated before.  </p>
  
  <pre><code>{
    "AL1" : [ {
      "AllergenCodeMnemonicDescription" : [ {
        "1" : {
          "Text" : "ASPIRIN",
          "ID" : "TEST1"
        },
        "2" : {
          "Text" : "TYLENOL",
          "ID" : "TEST2"
        }
      } ]
    }, {
      "SetIDAL1" : "1"
    }, {
      "AllergenCodeMnemonicDescription" : [ {
        "Text" : "ADVIL"
      } ]
    }, {
      "SetIDAL1" : "2"
    } ]
  }
  
  </code></pre>
  
  <p>Here is the output I need:</p>
  
  <pre><code>{
  
    "AL1": [
      {
        "AllergenCodeMnemonicDescription": [
          {
            "Text": "ASPIRIN",
            "ID": "TEST1"
          },
          {
            "Text": "TYLENOL",
            "ID": "TEST2"
          }
        ],
        "SetIDAL1": "1"
      },
      {
        "AllergenCodeMnemonicDescription": [
          {
            "Text": "ADVIL"
          }
        ],
        "SetIDAL1": "2"
      }
    ]
  }
  </code></pre>