Skip to content
Advertisement

How to put Json object through loop

I want to loop through the questionnaires by using the for loop to set the value of the EMAIL_TO_CLIENT_IND.

The value inside the “path” is QUESTIONNAIRES/SUB_QUESTION/EMAIL_TO_CLIENT_IND. The first “if” is if the level path in JSON is just one Ex. “Questionnaires”. And the “else” is for the path more than 1 Ex. “Questionnaires/Question”.

My current idea is put the jObject.getJSONObject() inside the “else” for loop.

enter image description here

enter image description here

Advertisement

Answer

You can use the JSONArray as follows

JavaScript

Edited

can be solved using GSON library also

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement