Json标准格式(json正确数据格式)

1.Exception in thread "main" com.alibaba.fastjson.JSONException: syntax error, expect {, actual ] 
就是说实际上想要的是{},而不是[]
错误案例: String request = "[\"data\"=\"today\", \"type\"=\"JSON\"]"

(只要是这种都是格式不正确,还有比如syntax error, expect :, actual =等等

错误案例: String request = "{\"data\"=\"today\", \"type\"=\"JSON\"}"

2.com.alibaba.fastjson.JSONException: syntax error,
错误案例: String request = "{data:today, type:JSON}";


正确案例:String request = "{\"data\":\"today\", \"type\":\"JSON\"}";
JSONObject obj = JSON.parseObject(request);
posted @ 2017-11-23 13:49  antime  阅读(16308)  评论(0编辑  收藏  举报