0

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"
}
Milo S
  • 4,466
  • 1
  • 19
  • 22
nilesh1212
  • 1,561
  • 2
  • 26
  • 60
  • 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 Nov 27 '17 at 13:50

2 Answers2

2

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
Rajesh A
  • 379
  • 3
  • 14
0

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

Milo S
  • 4,466
  • 1
  • 19
  • 22