String rs="[ { "name": "UserName", "displayName": "Username"},{ "name": "WeeksSinceRegistration", "displayName": "Weeks Since Registration" }]";
A JSONObject text must begin with '{' at character 1 of [ame of the这是报错息
JSONObject obj = JSONObject.fromObject(rs);
List> map = (List>) JSONObject.toBean(obj, List.class);
先添加 json 架包
String rs="[ { 'name': 'UserName','displayName': 'Username'},{ 'name': 'WeeksSinceRegistration', 'displayName': 'Weeks Since Registration' }]";
JSONArray arr =JSONArray.fromObject(rs);
for(Object o:arr){
JSONObject b=JSONObject.fromObject(o);
System.out.println(b.get("name"));
}
```
报错信息说了 JSON对象需要以 '{' 字符开头
15599020164
1.json用JSONObject来进行解析
2.json数组用JSONArray来进行解析
你的是数组,所以需要用JSONArray进行解析,希望能帮到你...
楼上说的对,你的是数组类的json。 用jsonarray解析。
楼主,你这是json数组请使用JSONArray来解析