[Solved] I want to build a JSON Object similar to following the structure in java using JSONObject and JSONArray. How can I do it?
You can try with JSONSimple library and form the object in this way- You have to import org.json.simple.JSONArray and org.json.simple.JSONObject for using this code. JSONObject object=new JSONObject(); JSONObject holder=new JSONObject(); JSONArray taskAssings = new JSONArray(); JSONObject taskAssigned=new JSONObject(); taskAssigned.put(“id”, “3c814009-82f7-4246-bc51-2d263e758561”); JSONObject taskAssignee=new JSONObject(); taskAssignee.put(“id”, “3c814009-82f7-4246-bc51-2d263e758561”); holder.put(“taskAssigned”,taskAssigned); holder.put(“taskAssignee”,taskAssignee); taskAssings.add(holder); object.put(“taskAssings”, taskAssings); JSONObject status=new JSONObject(); status.put(“id”, “7d8a0d80-5c93-46cc-982d-47399503beaa”); … Read more