【发布时间】:2020-05-03 14:13:14
【问题描述】:
我有一个这样的 JSON 对象,我需要使用 id 提取任何对象的 name 值。我已经尝试了许多不同的迭代,但我似乎无法得到任何工作。任何一般的指针将不胜感激。谢谢。
{
"weeks":[
{
"1":[
{
"name":"Stackoverflow Question",
"description":"Have you ever asked a question on StackoverFlow?",
"date":"11/25/2019",
"id":"whewhewhkahfasdjkhgjks"
},
{
"name":"I Can't Believe It's Not Butter!",
"description":"Can you believe it? I sure can't.",
"date":"11/25/2019",
"id":"agfasdgasdgasdgawe"
}
]
},
{
"2":[
{
"name":"Hello World",
"description":"A hello world.",
"date":"12/02/2019",
"id":"aewgasdgewa"
},
{
"name":"Testing 123",
"description":"Sometimes people don't say it be like it is but it do.",
"date":"12/04/2019",
"id":"asdgasdgasdgasd"
}
]
}
]
}
【问题讨论】:
-
向我们展示您迄今为止的尝试!
-
你真的把这个 JSON 对象转换成 Python 字典了吗?看看你的代码会很有帮助。
-
@KlausD。是的,我知道这是礼仪,我通常会这样做,问题是我刚刚尝试了各种零散的解决方案,然后将它们删除。道歉。