/* package whatever; // don't place package name! */ import java.io.*; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; import com.google.gson.Gson; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { static Gson gson = new Gson(); static Json3 innerchild = new Json3(); { JSONParser parser = new JSONParser(); JSONObject json = null; Json2 leaf = new Json2(); Json3 child = new Json3(); int len = parts.length; child.setAttributeName(parts[1]); JSONArray arr = new JSONArray(); if (len == 3) { leaf.setAttribute(leafNode); leaf.setLeaf(true); leaf.setChildren(arr); json = (JSONObject) parser.parse(gson.toJson(leaf)); child.setChildren(json); } else { for (int i = 2; i < parts.length - 1; i++) { if (len != i) { if (i == 3) { innerchild.setAttributeName(parts[i]); leaf.setAttribute(leafNode); leaf.setLeaf(true); json = (JSONObject) parser.parse(gson.toJson(leaf)); innerchild.setChildren(json); arr.add(innerchild); leaf.setChildren(arr); leaf.setLeaf(false); } else { leaf.setAttribute(parts[i]); leaf.setChildren(arr); json = (JSONObject) parser.parse(gson.toJson(leaf)); child.setChildren(json); } } } } if(parts.length != 3){ arr = new JSONArray(); arr.add(innerchild); leaf.setChildren(arr); json = (JSONObject) parser.parse(gson.toJson(leaf)); child.setChildren(json); } } }
1 2 10 42 11
Main.java:4: error: package org.json.simple does not exist
import org.json.simple.JSONArray;
^
Main.java:5: error: package org.json.simple does not exist
import org.json.simple.JSONObject;
^
Main.java:6: error: package org.json.simple.parser does not exist
import org.json.simple.parser.JSONParser;
^
Main.java:7: error: package org.json.simple.parser does not exist
import org.json.simple.parser.ParseException;
^
Main.java:9: error: package com.google.gson does not exist
import com.google.gson.Gson;
^
Main.java:15: error: cannot find symbol
static Gson gson = new Gson();
^
symbol: class Gson
location: class Ideone
Main.java:16: error: cannot find symbol
static Json3 innerchild = new Json3();
^
symbol: class Json3
location: class Ideone
Main.java:15: error: cannot find symbol
static Gson gson = new Gson();
^
symbol: class Gson
location: class Ideone
Main.java:16: error: cannot find symbol
static Json3 innerchild = new Json3();
^
symbol: class Json3
location: class Ideone
Main.java:20: error: cannot find symbol
JSONParser parser = new JSONParser();
^
symbol: class JSONParser
location: class Ideone
Main.java:20: error: cannot find symbol
JSONParser parser = new JSONParser();
^
symbol: class JSONParser
location: class Ideone
Main.java:21: error: cannot find symbol
JSONObject json = null;
^
symbol: class JSONObject
location: class Ideone
Main.java:22: error: cannot find symbol
Json2 leaf = new Json2();
^
symbol: class Json2
location: class Ideone
Main.java:22: error: cannot find symbol
Json2 leaf = new Json2();
^
symbol: class Json2
location: class Ideone
Main.java:23: error: cannot find symbol
Json3 child = new Json3();
^
symbol: class Json3
location: class Ideone
Main.java:23: error: cannot find symbol
Json3 child = new Json3();
^
symbol: class Json3
location: class Ideone
Main.java:29: error: cannot find symbol
JSONArray arr = new JSONArray();
^
symbol: class JSONArray
location: class Ideone
Main.java:29: error: cannot find symbol
JSONArray arr = new JSONArray();
^
symbol: class JSONArray
location: class Ideone
Main.java:34: error: cannot find symbol
json = (JSONObject) parser.parse(gson.toJson(leaf));
^
symbol: class JSONObject
location: class Ideone
Main.java:45: error: cannot find symbol
json = (JSONObject) parser.parse(gson.toJson(leaf));
^
symbol: class JSONObject
location: class Ideone
Main.java:53: error: cannot find symbol
json = (JSONObject) parser.parse(gson.toJson(leaf));
^
symbol: class JSONObject
location: class Ideone
Main.java:60: error: cannot find symbol
arr = new JSONArray();
^
symbol: class JSONArray
location: class Ideone
Main.java:63: error: cannot find symbol
json = (JSONObject) parser.parse(gson.toJson(leaf));
^
symbol: class JSONObject
location: class Ideone
23 errors
Standard output is empty