how do I iterate though a jsonarray in stringtemplate v4 in JAVA?

179 Views Asked by At

I have JSON object which holds the data and I want to generate the new JSON object with the help of String template 4 iterating over the input JSON.

Suppose I have an input JSON object as follow

Input json :-

{ "list": [ { "ID": "1", "NAME": "abc", "GROUPID": "12" }, { "ID": "2", "NAME": "pqr" } ] }

OutPut JSON should be:

{ "items": [ { "itemId": "1", "itemName": "abc" }, { "itemId": "2", "itemName": "pqr" } ] }

I have searched and tried few examples to get this done but am not able to iterate over the JSON array and access the attribute of the JSON object in string template.

0

There are 0 best solutions below