Guest User

Untitled

a guest
Jan 18th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. public JSONOutput(Map<String, Object> outputMap) {
  2. super(outputMap);
  3.  
  4. if (outputMap.isEmpty()) {
  5. responseJson.put("response", new JSONArray());
  6. }
  7.  
  8. else if(outputMap.size() == 1) {
  9. //obj - first element of LinkedHashMap
  10. if (obj instanceof ResultImpl) {
  11. responseJson.put("response", getJson((ResultImpl) obj));
  12. } else {
  13. responseJson.put("response", obj);
  14. }
  15. }
  16. else {
  17. for (Map.Entry<String, Object> entry : outputMap.entrySet()) {
  18. Object obj = entry.getValue();
  19.  
  20. if (obj instanceof ResultImpl) {
  21. responseJson.append("response", getJson((ResultImpl) obj));
  22. } else {
  23. responseJson.append("response", obj);
  24. }
  25. }
  26. }
  27. }
Add Comment
Please, Sign In to add comment