我正在尝试使用map(ObjectMapper and TypeReference)
在java中读取此文件,但map
只选择一个数据,即name: "David Roberts"
,slug: "david-robets"
和assigned: "assigned"
。
我也尝试使用JsonParser
,但没有得到合适的结果。
对此有任何建议:
{
"name": "David Roberts",
"slug": "david-roberts",
"assigned": "assigned"
},
{
"name": "Robert Chang",
"slug": "robert-chang",
"assigned": "assigned"
},
{
"name": "Chris Curtis",
"slug": "chris.curtis",
"assigned": "assigned",
"fileId": "1370206"
}
答案 0 :(得分:0)
您的json文件错误。 正确的格式是:
[{
"name": "David Roberts",
"slug": "david-roberts",
"assigned": "assigned"
},
{
"name": "Robert Chang",
"slug": "robert-chang",
"assigned": "assigned"
},
{
"name": "Chris Curtis",
"slug": "chris.curtis",
"assigned": "assigned",
"fileId": "1370206"
}]
答案 1 :(得分:0)
如果你想要所有的值,那么json应该是这样的。
{"values":[{
"name": "David Roberts",
"slug": "david-roberts",
"assigned": "assigned"
},
{
"name": "Robert Chang",
"slug": "robert-chang",
"assigned": "assigned"
},
{
"name": "Chris Curtis",
"slug": "chris.curtis",
"assigned": "assigned",
"fileId": "1370206"
}]
}