1
score
197
views
no
status
CC BY-SA 3.0
JSON Object should not add if it is repeated
If I understand correctly, you want the output to be like the second JSON array in your question. Changing where you loop should do the trick: I tested with the input you have. Here is the formatted JSON output: