I just want to construct JSON object something like this:
"Root":{
"c1": "v1"
}
I tried with the following code :
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
public class Exe {
public static void main(String[] args) throws JSONException {
JSONObject object = new JSONObject("ROOT");
object.put("c1", "v1");
System.out.println(object.toString());
}
}
with this code, I got the following exception:
Exception in thread "main" org.codehaus.jettison.json.JSONException: A JSONObject text must begin with '{' at character 1 of ROOT
I played with codehaus API, but I didn't find the solution, so can you please help me on this.