问答详情
源自:3-1 JSON使用

在json中new String[]出现了乱码

Object  nullObj = null; 

private static void JSONObject() {

// TODO Auto-generated method stub

JSONObject wangxiaoer = new JSONObject();


wangxiaoer.put("name", "王小二");

wangxiaoer.put("age", 25.2);

wangxiaoer.put("birthday", "1990-01-01");

wangxiaoer.put("major" ,new String[]{"炒菜","挖掘机"});

wangxiaoer.put("car",nullObj);

wangxiaoer.put("house",nullObj);

System.out.println(wangxiaoer.toString());

}

}

得出来的结果是这样的

{"car":null,"birthday":"1990-01-01","age":25.2,"name":"王小二","house":null,"major":[Ljava.lang.String;@b166b5}



提问者:qq_慕码人5248226 2019-08-27 18:03

个回答

  • 带带大师兄i
    2019-09-11 10:38:24


    private static void JSONObject() {

    Object  nullObj = null; 

    JSONObject wangxiaoer = new JSONObject();


    wangxiaoer.put("name", "王小二");

    wangxiaoer.put("age", 25.2);

    wangxiaoer.put("birthday", "1990-01-01");

    wangxiaoer.put("major" ,new String[]{"炒菜","挖掘机"});

    wangxiaoer.put("car",nullObj);

    wangxiaoer.put("house",nullObj);

    System.out.println(wangxiaoer.toString());

    }

    }


    酱紫