我有一个JSON,结构如下-
{
"gridDefinition": {},
"zoneDefinitions": [
{
"status": "Pending",
"name": "xxx-1",
"globalName": "xxx-2",
"id": 10,
"memory": "1234",
"cores": "0",
"VM": [
{
"ipAddress": "1.2.3.4",
"hostname": "zzzzz-1"
},
{
"ipAddress": "2.3.4.5",
"type": "virtual"
}
]
}
]
}
我需要解析它并在控制台上显示,使用相同的结构,但是没有所有的“[]”和“{}”。你知道吗
比如:
gridDefinition:
zoneDefinitions:
Status:Pending
name:xxx-1
id:10
memory:1234
cores:0
VM:
ipAddress : 1.2.3.4
hostname : zzzzz-1
ipAddress:2.3.4.5
.......
.........
.............
我尝试了pretty printing json上提到的几个递归解决方案
但这没有成功。你知道吗
可能有任何级别的数组和字典嵌套,我需要保留缩进并在控制台上打印它们。你知道吗
有人能告诉我怎么做吗?你知道吗
我决定把这本书翻个底朝天,然后想出一个可以打印这本书的东西:
脚本是:
相关问题 更多 >
编程相关推荐