Convert a JSON string to object in Java ME?

前端 未结 14 921
有刺的猬
有刺的猬 2020-11-22 02:12

Is there a way in Java/J2ME to convert a string, such as:

{name:\"MyNode\", width:200, height:100}

to an internal Object representation of

14条回答
  •  醉话见心
    2020-11-22 03:14

    Just make a Json object in java with the following Json String.In your case

    {name:"MyNode", width:200, height:100}
    

    if the above is your Json string , just create a Json Object with it.

    JsonString ="{name:"MyNode", width:200, height:100}";
    JSONObject yourJsonObject = new JSONObject(JsonString);
    System.out.println("name=" + yourJsonObject.getString("name"));
    System.out.println("width=" + yourJsonObject.getString("width"));
    

提交回复
热议问题