Android 我有一个json,但不知道如何解析它
数组中有一个名为children的字符串,在该子数组中可以有另一个子数组,在该子数组中又可以有另一个子数组。请帮助我分析该字符串 json的格式如下 我有一个json响应,它在数组的内部有数组。我想获取给定标记的所有值Android 我有一个json,但不知道如何解析它,android,parsing,Android,Parsing,数组中有一个名为children的字符串,在该子数组中可以有另一个子数组,在该子数组中又可以有另一个子数组。请帮助我分析该字符串 json的格式如下 我有一个json响应,它在数组的内部有数组。我想获取给定标记的所有值 { "id": "fe13e84e-fa26-46fb-bd39-6b581dad9eb7", "type": "data", "title": "root", "children": [ { "id": "d6426ce9-e243-40
{
"id": "fe13e84e-fa26-46fb-bd39-6b581dad9eb7",
"type": "data",
"title": "root",
"children": [
{
"id": "d6426ce9-e243-40b1-93f5-a1aaa3193a4c",
"type": "group",
"title": "first",
"children": [
{
"id": "b3d888b1-c4f0-4337-87a3-d51961d81c0b",
"type": "class",
"title": "A",
"children": [
{
"id": "df0a218d-7a08-4295-abb7-e0bdfb835414",
"type": "color",
"title": "red",
"children": [
{
"id": "7c451766-5f91-48f5-8db5-868e7cc95905",
"type": "taste",
"title": "sour",
"children": [
{
"id": "2567b1f1-2662-48fd-a487-167e514ce5d8",
"type": "size",
"title": "tiny"
},
{
"id": "29a73327-d5be-44cc-8c1d-e45ddb8be2b7",
"type": "size",
"title": "small"
},
{
"id": "718d54cf-ce19-44e9-9a94-3214ef482dc2",
"type": "size",
"title": "medium"
},
{
"id": "f1f81f3a-be49-411d-b176-0d1e67f18864",
"type": "size",
"title": "large"
},
{
"id": "ccbe91ef-7dec-4dc7-bbf5-ef79161670df",
"type": "size",
"title": "huge"
}
]
},
{
"id": "7b9ae76c-d189-4b44-9ea1-ea38b05d35ae",
"type": "taste",
"title": "bitter",
"children": [
{
"id": "42b7f578-e907-475d-beb3-d1d53af1bec9",
"type": "size",
"title": "tiny"
},
{
"id": "acaed672-d5df-43a2-9e30-5cf55f74b1ce",
"type": "size",
"title": "small"
},
{
"id": "d4785d0b-9116-4361-8349-505934ceb9c9",
"type": "size",
"title": "medium"
},
{
"id": "7ee5494f-dc36-45e2-bc09-2ac948133523",
"type": "size",
"title": "large"
},
{
"id": "0ded484b-78f2-497e-bdfe-c9bd2ba78368",
"type": "size",
"title": "huge"
}
]
},
}
如果JSON是有效的,那么您可以通过创建POJO轻松获得所有想要的值,这可以通过POJO生成器工具生成。您甚至不需要解析JSON。只需通过GSON库将JSON映射到JavaPOJO类并使用它
POJO生成器->使用递归(或仅使用
GSON
)可能的重复项不是有效的JSON。复制并粘贴json以查看它是否有效。您有任何示例吗?如果我们在发布后添加逗号,它将有效