[英]How do I access the $ref in the JSON and get the 'type' in properties, given a key path in JSON?
[英]How do I get the next json key?
有這樣一個json:
{
"id": "1994",
"schedule": {
"1": {
"title": "Понедельник",
"schedule": {
"4": {
"1": {
完整版: https : //pastebin.com/wLX6D0w
我輸出schedule['schedule']['1']['schedule'],但是我怎么得到下一個key(json文件可以改變,key值也可以。在這種情況下,它等於4) ?
使用索引? 如何?
我找到了解決方案。 這是schedule['schedule'][str(weekday_list.get(dayWeek))]['schedule'].keys()
import json
jsn = {
"id": "1994",
"schedule": {
"1": {
"title": "LOL",
"schedule": {
"4": {
"1": {
}
}
}
}
}
}
# dumping jsn variable from !!!PYTHON!!! dict to string
step_one = json.dumps(jsn)
# loading dumped jsn variable from string to !!!JSON!!!
step_two = json.loads(step_one)
print(step_two['schedule']['1'])
print(step_two['schedule']['1']['schedule'])
print(step_two['schedule']['1']['schedule']['4'])
print(step_two['schedule']['1']['schedule']['4']['1'])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.