亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

java - JSon字符串轉(zhuǎn)JSON對(duì)象?
大家講道理
大家講道理 2017-04-18 10:52:09
0
4
583

String userStr=readJSONString(request);

        System.out.println(userStr);//能輸出
        JSONObject jsonObj = JSONObject.fromObject(userStr);//我感覺(jué)這有問(wèn)題

        System.out.println(jsonObj.getInt("userid"));//后臺(tái)沒(méi)輸出
        System.out.println(jsonObj.getString("username"));
        輸出結(jié)果如下

大家講道理
大家講道理

光陰似箭催人老,日月如移越少年。

reply all(4)
Peter_Zhu

should be JSONObject import錯(cuò)了,或者是版本不對(duì)吧,我本地用的是 json-lib-2.4 net.sf.json.JSONObject, which is OK.

巴扎黑

If the frontend transmits json type data, then the backend receives json type data, and there is no need to transfer it anymore

PHPzhong

1. First confirm whether your userStr is a json string:
For example: String jstr="{'json':'jsonvalue','bool':true,'int':1,'double':'20.5'} ";
2. Then check whether the JOSNObject you are using is the json.jar package.
3. Confirm whether your json package is imported correctly.

伊謝爾倫

First take a look at the package introduction of the net.sf.json.JSONObject version mentioned by taomaokun, and then check whether your json string is written correctly. This is generally available

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template