后端接收json参数转为map,适用于包含数组的json参数
import com.alibaba.fastjson.JSON;
Map maps = (Map) JSON.parse(result );
JSONArray jsonArr = JSONArray.fromObject(maps.get("ResultInfo"));
for (int i = 0 ; i < jsonArr.size() ; i ++){
Map map = (Map) jsonArr.get(i);
//单据号码
String invoiceNo = (String)map.get("InvoiceNo");
//发票编号
String vatNo = (String)map.get("VatNo");
//发票代码
String vatCode = (String) map.get("VatCode");
//发票url
String url = (String)map.get("FileUrl");
//xxxxxxxxxxxx
}
/**
* 测试数据
*/
String result = "{ \n" +
" \"IsSuccess\": true, \n" +
" \"Msg\": \"获取成功\", \n" +
" \"ResultInfo\": [{ \n" +
" \"InvoiceNo\": \"MY0706-1\", \n" +
" \"VatCode\": \"1234567890\", \n" +
" \"VatNo\": \"88888888\", \n" +
" \"VatDate\": \"2022-06-09\", \n" +
" \"VatAmt\": 100, \n" +
" \"VatTaxAmt\": 13, \n" +
" \"VatAmtIncludeTax\": 113, \n" +
" \"FileUrl\": \n" +
"\"发票url\" \n" +
" }] \n" +
"}";