bazaarvoice / jolt

JSON to JSON transformation library written in Java.
Apache License 2.0
1.56k stars 329 forks source link

What kind of Spec Array to Output key value pairs where key is a data value in input array and value is array #1111

Open AKulkarniZT opened 2 years ago

AKulkarniZT commented 2 years ago

Input:

"aggregations:"{
    "masterId" : {
      "doc_count_error_upper_bound" : 0,
      "sum_other_doc_count" : 0,
      "buckets" : [
        {
          "key" : "1Q52",
          "doc_count" : 3,
          "serialNumbers" : {
            "doc_count_error_upper_bound" : 0,
            "sum_other_doc_count" : 0,
            "buckets" : [
              {
                "key" : "3R24Z3",
                "count" : 1
              },
              {
                "key" : "526GA2",
                "count" : 1
              },
              {
                "key" : "873XHE",
                "count" : 1
              }
            ]
          }
        }
      ]
    }
  }

Spec: Trying to figure this out

Desired Output:

{"1Q52": ["3R24Z3", "526GA2", "873XHE"]}

My current Spec array is

[{
        "operation": "shift",
        "spec": {
            "aggregations": {
                "masterId": {
                    "buckets": {
                        "*": {
                            "key": "key",
                            "serialNumbers": {
                                "buckets": {
                                    "*": {
                                        "key": "key"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
}]

and my current output is

{"key":["1Q52","3R24Z3", "526GA2", "873XHE"]}

What kind of spec array could give me the desired output?

AKulkarniZT commented 2 years ago

Got an answer here