java我们可以逐个读取Json文件负载吗
我们在json文件中有2条记录,我想逐一读取并将其发送到RESTAPI。 我们可以在一个列表中获取这些记录,或者可以在单个有效负载中逐个读取这些记录。我们怎么分呢
{
"batchSize": 0,
"debug": true,
"records": [
{
"firstName": "Maria Farj Hassan",
"address": {
"postcode": "100001",
"longitude": 180
},
"birthDay": "1980-06-30",
"startTime": 1485167477,
"_meta": {
"type": "customer.dedup",
"id": "1",
"status": "ACTIVE",
"businessId": "1",
}
}
]
}
第二条记录是:
{
"batchSize": 0,
"debug": true,
"records": [
{
"firstName": "Maria Hassan",
"address": {
"postcode": "100001",
"longitude": 180
},
"birthDay": "1980-06-30",
"partyType": 1,
"startTime": 1485167477,
"_meta": {
"type": "customer.dedup",
"id": "1",
"status": "ACTIVE"
}
}
]
}
# 1 楼答案
假设您的Json文件如下所示(我只是将两个记录合并到一个Json数组中)
下面是一个示例代码,演示如何将此json文件与数据提供程序一起使用
您需要添加以下内容作为Maven依赖项(Google gson依赖项)