java解析Json中获取Array字段值及嵌套Json对象

获取响应内容:{"code":0,"message":"成功","data":{"docs":[{"fileId":"5cb99cccba6742ced9c894c019594015c7","fileName":"张三2021-01-27.pdf","fileUrl":"https://es33ig34noss.esign.cn/111156373486/3ce0c10d-c6cc-4a99-aa85-e2c1aa0065c2/%E9%BB%84%E6%89%BF%E5%AE%872021-01-27.pdf?Expires=1611753564&OSSAccessKeyId=LTAI4GJDCzRmsaAhkYbZFxUS&Signature=LhPXTAcU5%2FJQDzrggVV6J6aG%2FRE%3D"}]}}

java解析Json中获取Array字段值及嵌套Json对象

		JSONObject downloadJson = SignHelper.downloadFlowDoc(flowId);
        JSONObject json = null;
        String address2 = null;
        json = new JSONObject(downloadJson);
        JSONArray jsonarr= json.getJSONArray("docs");
        System.out.println("jsonarr==" + jsonarr);
        String address1 = jsonarr.getJSONObject(0).getString("fileUrl");
        address2 = jsonarr.getJSONObject(0).getString("fileId");
        System.out.println("address1==" + address1);
        System.out.println("address2==" + address2);

java解析Json中获取Array字段值及嵌套Json对象

上一篇:Java解析json数组三种情况


下一篇:JSONObject、JSONArray、Map、JavaBean相互转换