I have input json HTTP response in below format. I want to extract only few fields from Json and put them in CSV format. I want to write Groovy script to read json and write it to csv format.
Input json file:
{
"Links": {},
"Items": [
{
"Timestamp": "2019-11-20T01:51:11.8660125Z",
"Value": 36.77309,
"UnitsAbbreviation": "",
"Good": true,
"Questionable": false,
"Substituted": false
},
{
"Timestamp": "2019-11-20T02:17:19.7750091Z",
"Value": 36.8910828,
"UnitsAbbreviation": "",
"Good": true,
"Questionable": false,
"Substituted": false
}
],
"UnitsAbbreviation": "AHK"
}
Expected Output csv format:
Timestamp,Value
"2019-11-20T01:51:11.8660125Z",36.77309
"2019-11-20T02:17:19.7750091Z",36.8910828
Can anyone help me with sample Groovy code as I am new to Groovy? I dont want to complicate the flow with multiple process like splitting the json, evaluate json and write to csv.
Any help or pointers would be appreciable. Thanks.