0
votes

I am trying to do JSON to JSON transformation using jolt, I have below sample JSON wants to convert to expected JSON. Can you please help me with this using jolt library. I also want to add a new key-value pair "created_ts" tag which will hold value for current timestamp in expected JSON.

Sample JSON

{
  "name": "SAMPLE_NAME",
  "timeStamp": "1477307252000",
  "value": "-0.06279052",
  "quality": "1090"
}

Expected Output JSON:

{
  "name": "SAMPLE_NAME",
  "timeStamp": "2016-11-08 14:46:13.674",
  "value": "-0.06279052",
  "quality": "1090",
  "created_ts": "2016-11-08 14:46:13.674"
}
2
I am able to add new field created_ts using jolt, but still struggling with how to convert "timeStamp": "1477307252000" to "timeStamp": "2016-11-08 14:46:13.674" format. - nilesh1212

2 Answers

2
votes

Keep as simple, use replaceText processor with this configuration:

Search Value         :  }\s+}
Replacement Value    :  { "created_ts":"${now()}",
Replacement Strategy :  Regex Replace
Evaluation Mode      :  Entire text
0
votes

Jolt currently does not offer an "Out of the Box" way to do String/Number/Date conversions.