0
votes

I am looking at the prefix soup example from jolt-demo.appspot, which seems to be almost exactly what I need however I made a minor modification on the input to have multiple objects in an array, then I changed the spec to have * wildcard to account for the array and the result is not exactly how I need it. I'm obviously missing something fundamental but I don't know what. Any help would be greatly appreciated.

Input JSON

[
  {
    "rating-primary": 1,
    "rating-Price": 2,
    "rating-Design": 4,
    "rating-RatingDimension3": 1
  },
  {
    "rating-primary": 7,
    "rating-Price": 8,
    "rating-Design": 9,
    "rating-RatingDimension3": 10
  }
]

Spec

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "rating-primary": "Rating",
        "rating-*": "SecondaryRatings.&(0,1)"
      }
    }
  }
]

Expected Output

[
    {
        "Rating": 1,
        "SecondaryRatings": {
            "Primary": 1,
            "Price": 2,
            "Design": 4,
            "RatingDimension3": 1
        }
    },
    {
        "Rating": 7,
        "SecondaryRatings": {
            "Primary": 1,
            "Price": 2,
            "Design": 4,
            "RatingDimension3": 1
        }
    }
]

Actual Output

{
  "Rating" : [ 1, 7 ],
  "SecondaryRatings" : {
    "Price" : [ 2, 8 ],
    "Design" : [ 4, 9 ],
    "RatingDimension3" : [ 1, 10 ]
  }
}
1

1 Answers

0
votes

I figured it out. Here is the spec in case anyone else needs it.

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "rating-*": "[&1].SecondaryRatings.&(0,1)",
        "rating-primary": "[&1].Rating"
      }
    }
  }
]
'''