JSONObject()为null

时间:2017-11-25 20:46:20

标签: java android json

这是决心! 请参阅以下链接: How to "unit-test" json parsing on Android (JSONObject == "null")?

当我尝试创建JSONObject时,它返回null。 我不知道发生了什么。 它没有任何异常。

public class JSONTest {
@Test
public void test(){
    try {
        JSONObject testobj = new JSONObject();
        testobj.put("A", "aaa");
        testobj.put("B", 123);
        testobj.put("C", 1.2345);
        testobj.put("D", true);
        String data = testobj.toString();
        System.out.print("jsonData:"+data);
    } catch (JSONException e) {
        e.printStackTrace();
    }


}

}

Debuging mode Finish "Runing"

0 个答案:

没有答案
相关问题