{"result":[{"postnumber":"030006","province":"山西省","city":"太原市","district":"小店区","address":"坞城西街","jd":"山西省太原市小店区"},{"postnumber":"030012","province":"山西省","city":"太原市","district":"小店区","address":"长治路18-128(双号)","jd":"山西省太原市小店区"}]
1.这种数据是不是要用josnarray来解析,可是我的jsonarray的构造方法只能传boolen的数据是怎么回事
2.jsonobject的也是,这是怎么回事呢,我看网上他们都能传string啊
问题是:我要取出[{}]里面的某一行数据,就是说我的jsonobject的构造方法不能传string,无语
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; public class Test { public static void main(String[] args) { String json = "{\"total\":384,\"result\":[{\"postnumber\":\"030006\",\"province\":\"山西省\",\"city\":\"太原市\",\"district\":\"小店区\",\"address\":\"坞城西街\",\"jd\":\"山西省太原市小店区\"},{\"postnumber\":\"030012\",\"province\":\"山西省\",\"city\":\"太原市\",\"district\":\"小店区\",\"address\":\"长治路18-128(双号)\",\"jd\":\"山西省太原市小店区\"}]}"; JSONObject obj = JSON.parseObject(json); System.out.println(obj); } }
输出
{"result":[{"address":"坞城西街","province":"山西省","city":"太原市","district":"小店区","postnumber":"030006","jd":"山西省太原市小店区"},{"address":"长治路18-128(双号)","province":"山西省","city":"太原市","district":"小店区","postnumber":"030012","jd":"山西省太原市小店区"}],"total":384}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。