json格式实例
jsonLianXi.json:
{
"Data": {
"Page1": [
{
"FVoucherInterID": "",
"FVoucherInterID1": "",
"FLockBill": 0,
"FClassTypeID": 1000004,
"FJSDate": null,
"FJSBillNo": "",
"FSysStatus": 2,
"FPrintCount": 0,
"FBillNo": "CGZP000306",
"FDate": "2019-12-18 00:00:00",
"FPayCondition": {
"FNumber": "",
"FName": ""
},
"FFincDate": "2019-12-18 00:00:00",
"FItemClassID": {
"FNumber": "008",
"FName": "供应商"
},
"FExchangeRateType": {
"FNumber": "01",
"FName": "公司汇率"
},
"FRemainAmountBill": 0.0000,
"FArApStatus": 7,
"FCurrencyID": {
"FNumber": "RMB",
"FName": "人民币"
},
"FSupplyID": {
"FNumber": "02.05",
"FName": "徐州利勃海尔混凝土机械有限公司"
},
"FTotalExpenseFor": 0.0000000000,
"FInterID": 1721,
"FCheckAmountBill": 102000.0000,
"FCheckAmountForBill": 102000.0000,
"FTrade": null,
"FRemainAmountForBill": 0.0000,
"FPeriod": 0,
"FBillStatus": 0,
"FBillStatus1": 0,
"FCheckDate": null,
"FVchInterID": null,
"FROB": 0,
"FTranType": 0,
"FTotalExpense": 0.0000000000,
"FTaxNum": "",
"FOffsetTaxFor": 0.0000000000,
"FYearPeriod": null,
"FSubSystemID": 1,
"FAccount": "",
"FAddress": "",
"FHookerID": {
"FNumber": "",
"FName": ""
},
"FAdjustExchangeRate": 1.0000000000,
"FOffsetTax": 0.0000000000,
"FExchangeRate": 1.0,
"FAcctID": {
"FNumber": "1122.01",
"FName": "内贸"
},
"FBank": "",
"FYear": 2019,
"FStatus": 0,
"FRegion": null,
"FAdjustAmount": 0.0000,
"FNote": "摘要20191218",
"FInterestRate": 0.0000000000,
"FCompactNo": "备注(合同号)20191218",
"FPOStyle": {
"FNumber": "PO02",
"FName": "赊购"
},
"FTotalCostFor": 58.5000000000,
"FTotalCost": 0.0000000000,
"FCheckerID": {
"FNumber": "",
"FName": ""
},
"FBillerID": {
"FNumber": "郭林",
"FName": "郭林"
},
"FDeptID": {
"FNumber": "01.02.058",
"FName": "加纳"
},
"FEmpID": {
"FNumber": "10112286",
"FName": "粱峰"
},
"FPosterID": null,
"FTaskID": {
"FNumber": "",
"FName": ""
},
"FResourceID": {
"FNumber": "",
"FName": ""
},
"FOrderID": {
"FNumber": "",
"FName": ""
},
"FFreeItem3": "",
"FFreeItem4": "",
"FOrderAmountFor": 0,
"FBudgetAmountFor": 0.0000000000,
"FBillerName": "",
"FObtainRateWay": 0,
"FNumber": ""
}
],
"Page2": [
{
"fdate_2": "2019-12-18 00:00:00",
"FAmountFor": 102000.0000000000,
"FOrgID": 10934,
"FAmount2": 0.0000000000,
"FRemainAmount": 0.0000000000,
"FRemainAmountFor": 0.0000000000,
"FRP": 0,
"FEntryID2": 1,
"FDetailID2": 2186,
"FInterID2": 1721,
"FNumber": ""
}
],
"Page3": [
{
"FFreeItem3_3": "",
"FFreeItem4_3": "",
"FLinkCheckQty": 2.0000000000,
"FLinkCheckAmountFor": 102000.0000,
"FLinkCheckAmount": 0.0000,
"FItemID": {
"FNumber": "01.01.03",
"FName": "SX1194JM461"
},
"FItemID36422": "SX1194JM461",
"FItemID36436": "",
"FUnitID": {
"FNumber": "01.01",
"FName": "辆"
},
"FBaseUnit": "辆",
"FAuxQty": 2.0000000000,
"FQuantityPayApply_Commit": 0.0000000000,
"FQuantityReceive_Commit": 2.0000000000,
"FsecCoefficient": 0.0000000000,
"FSecQty": 0.0000000000,
"FAuxPrice": 45000.0000000000,
"FAuxTaxPrice": 45000.0000000000,
"FDiscountRate": 15.0000000000,
"FPriceDiscount": 38250.0000000000,
"FSourceInterId": 0,
"FAmtDiscount": 0.0000,
"FStdAmtDiscount": 0.0000,
"FAmount3": 40000.0000000000,
"FStdAmount": 0.0000,
"FPrice": 45000.0000000000,
"FQty": 2.0000000000,
"FTaxPrice": 45000.0000000000,
"FTaxRate": 17.0000000000,
"FTaxAmount": 6800.0000000000,
"FOrderType": 0,
"FStdTaxAmount": 0.0000,
"FAmountIncludeTax": 46800.0000000000,
"FStdAmountIncludeTax": 0.0000000000,
"FAmountMust": 0.0000,
"FDeductTax": 0.0000000000,
"FAuxOrderPrice": 0.0000000000,
"FOrderPrice": 0.0000000000,
"FNote_3": "",
"FBatchNo": "",
"FSourceBillNo": "",
"FPayApplyAmountFor": 0.0000,
"FPayReqPayAmountFor": 0.00,
"FContractBillNo": "",
"FPayApplyAmount": 0.0000,
"FOrderBillNo": "",
"FCheckAmountFor": 46800.0000,
"FCheckAmount": 0.0000,
"FRemainAmountForEntry": 0.0000,
"FRemainAmountEntry": 0.0000,
"FCheckQty": 2.0000000000,
"FRemainQty": 0.0000000000,
"FInvLinkCheckAmount": 0.0000,
"FInvoiceAmount": 0.0000,
"FInvoiceAmountFor": 0.0000,
"FInvLinkCheckAmountFor": 0.0000,
"FInvLinkCheckQty": 0.0000000000,
"FInvoiceQty": 0.0000000000,
"FSourceTranType": 0,
"FAmountFor_Commit": 46800.0000,
"FAmount_Commit": 0.0000,
"FEntryID3": 1,
"FDetailID3": 917,
"FInterID3": 1721,
"FContractEntryID": 0,
"FEntryID_SRC": 0,
"FOrderEntryID": 0,
"FOrderInterID": 0,
"FClassID_SRC": {
"FNumber": "",
"FName": ""
},
"FSourceEntryID": 0,
"FAuxPropID": {
"FNumber": "",
"FName": ""
},
"FSecUnitID": {
"FNumber": "",
"FName": ""
},
"FNumber": ""
}
]
}
}
java代码:
package com.linkpal.integrated.test;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.Map;
import org.apache.commons.collections.map.HashedMap;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
public class PaymoneyserviceImpl_Test {
public static void main(String[] args) {
String charset = "utf-8";
File file = new File("D:\\java\\sts\\sqgx\\src\\jsonLianXi.json");
long fileByteLength = file.length();
byte[] content = new byte[(int) fileByteLength];
FileInputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream(file);
fileInputStream.read(content);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
fileInputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
String str = null;
try {
str = new String(content, charset);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
JSONObject payMoneyObj = JSONObject.parseObject(str);
JSONObject jsonData = payMoneyObj.getJSONObject("Data");
System.out.println("date---"+jsonData);
JSONArray jsonPage1 =jsonData.getJSONArray("Page1");
System.err.println("jsonPage1----------------"+jsonPage1);
JSONArray jsonPage3 =jsonData.getJSONArray("Page3");
Map map=new HashedMap();
/*******************************************第一种方法************************************************/
// System.out.println("jsonpage1--------"+jsonPage1);
JSONObject object = (JSONObject) jsonPage1.getJSONObject(0).get("FExchangeRateType");
System.out.println("object----"+object);
String string = object.getString("FName");
System.out.println("string===="+string);
String FDetailID3 =jsonPage3.getJSONObject(0).getString("FDetailID3");
System.err.println("FBillNo2===="+FDetailID3);
/**************************************************第二种方法******************************************************/
// for (int i=0;i