gpt4 book ai didi

java - gson json 解析器 : value without key

转载 作者:搜寻专家 更新时间:2023-10-31 20:30:00 25 4
gpt4 key购买 nike

我想像这样解析一个json结构:

{"response":
{
"arr1":[count,{...}],
"arr2":[count,{...}]
}
}

如果 count 有键“count”(例如),则一切正常。但是 key 是空的。有什么方法可以映射这个结构并仅手动检索这个值,或者我需要在没有 gson 的情况下自己解析所有这些 json?

已更新

这是一个有效的 json(用 http://jsonlint.com/ 检查过)

{
"response": {
"arr1": [
615,
{
"body": "hi",
"title": "Re(2): ..."
},
{
"body": "hello",
"title": "Re(23): ..."
}
],
"arr2": [
132,
{
"body": "hi",
"title": "Re(2): ..."
},
{
"body": "hello",
"title": "Re(23): ..."
}
]
}
}

最佳答案

如果你想解析任意集合你应该阅读Serializing and Deserializing Collection with Objects of Arbitrary Types并查看示例代码 example code .

关于java - gson json 解析器 : value without key,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10800508/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com