Guest User

Untitled

a guest
Oct 7th, 2021
527
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. try {
  2. JSONObject object = new JSONObject(json);
  3. JSONObject q = object.getJSONObject(uid);
  4. if(children[0].length() == 0){
  5. for (int i = 1; i < children.length; i++) {
  6. if (q.has(children[i])) {
  7. if (i < (children.length - 1)) {
  8. try {
  9. q = q.getJSONObject(children[i]);
  10. }catch (Exception ignored){
  11. q.remove(children[i]);
  12. for (int x = i; x < children.length; x++) {
  13. if(x<(children.length-1)){
  14. q.put(children[x],new JSONObject());
  15. q = q.getJSONObject(children[x]);
  16. }else {
  17. q.put(children[x],valu);
  18. }
  19. }
  20. }
  21. } else {
  22. q.put(children[i], valu);
  23. }
  24. } else {
  25. if (i < (children.length - 1)) {
  26. JSONObject j = new JSONObject();
  27. q.put(children[i], j);
  28. q = q.getJSONObject(children[i]);
  29. } else {
  30. q.put(children[i], valu);
  31. }
  32. }
  33. updateFil(object.toString());
  34. System.out.println(object);
  35. }
  36. }
  37. } catch (Exception e) {
  38. System.out.println("Something went wrong " + e);
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment