0
votes

I've to remove _id field, prefix date with $date and remove JSON from the input JSON. Can anyone help to achieve this using JOLT spec?

INPUT:

{
   "JSON":{
      "_id":{
         "oid":"5f9122213f077e24b639d084"
      },
      "name":"Mongodb",
      "age":"98",
      "ttlTime":{
         "date":1536165487000
      }
   }
}

Expected Output:

{
   "name":"Mongodb",
   "age":"98",
   "ttlTime":{
      "$date":1536165487000
   }
}

I'm using the below spec, but not getting the desired output. JOLT spec:

[
   {
      "operation":"remove",
      "spec":{
         "JSON":{
            "_id":""
         }
      }
   },
   {
      "operation":"shift",
      "spec":{
         "JSON":{
            "ttlTime":{
               "date":"ttlTime.\\$date"
            }
         },
         "*":"&",
         "JSON":""
      }
   }
]
1

1 Answers

0
votes

check this spec,

[
  {
    "operation": "shift",
    "spec": {
      "JSON": {
        "name": "name",
        "age": "age",
        "ttlTime": {
          "date": "ttlTime.\\$date"
        }
      }
    }
  }
]