Required OutPut :
[{
candidates: {
id:"agent_4",
text = "can i get a confirmation code",
count = 2},
{
id:"agent_11",
text = "text_2",
count =3},
}]
I got the similar question for JQ, but how can I achieve this in java? Convert TSV file to multiple JSON arrays with jq
Load file by BufferedReader and use JsonArray to format your Json output