Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- JSONObject object = new JSONObject(json);
- JSONObject q = object.getJSONObject(uid);
- if(children[0].length() == 0){
- for (int i = 1; i < children.length; i++) {
- if (q.has(children[i])) {
- if (i < (children.length - 1)) {
- try {
- q = q.getJSONObject(children[i]);
- }catch (Exception ignored){
- q.remove(children[i]);
- for (int x = i; x < children.length; x++) {
- if(x<(children.length-1)){
- q.put(children[x],new JSONObject());
- q = q.getJSONObject(children[x]);
- }else {
- q.put(children[x],valu);
- }
- }
- }
- } else {
- q.put(children[i], valu);
- }
- } else {
- if (i < (children.length - 1)) {
- JSONObject j = new JSONObject();
- q.put(children[i], j);
- q = q.getJSONObject(children[i]);
- } else {
- q.put(children[i], valu);
- }
- }
- updateFil(object.toString());
- System.out.println(object);
- }
- }
- } catch (Exception e) {
- System.out.println("Something went wrong " + e);
- }
Advertisement
Add Comment
Please, Sign In to add comment