【发布时间】:2017-03-02 08:19:15
【问题描述】:
如何从包含多个 JSON 的文件中读取 JSON?
我的意思是,我看起来像这样:
{
"status": false,
"info": "The email field is required."
}
{
"status": false,
"info": "The email field is required."
}
{
"status": false,
"info": "The email field is required."
}
{
"status": false,
"info": "The email field is required."
}
{
"status": false,
"info": "The email field is required."
}
{
"status": false,
"info": "The email field is required."
}
例如我想获得一个 JSON 数组或读取 JSON 编号 1 或 4 的机会。
【问题讨论】:
-
如果你不能影响json文件,你可以使用像jackson这样的库,你可以自定义解析,但不必手动做所有事情。
-
然后在流的开头添加“[”并在结尾添加“]”,您将拥有
JSONArray的JSONObjects -
@pskink 但是如果我不能修改这个文件怎么办?有没有办法将 JSON 读取到数组或类似的东西?
-
好吧忘了我说的,我没有注意到元素没有用“,”字符分隔,所以我说的不起作用
标签: android json file android-studio assets