我有一个像下面这样的json:
{"widget": {
"debug": "on",
"window": {
"title": "SampleWidget",
"name": "main_window",
"width": 500,
"height": 500
},
"image": {
"src": "Images/Sun.png",
"name": "sun1",
"hOffset": 250,
"vOffset": 250,
"alignment": "center"
},
"text": {
"data": "Click Here",
"size": 36,
"style": "bold",
"name": "text1",
"hOffset": 250,
"vOffset": 100,
"alignment": "center",
"onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"
}
}}
Run Code Online (Sandbox Code Playgroud)
我需要提取所有的键值对。例如debug=on,title=SampleWidget,name=main_window等等。我怎样才能以通用方式做到这一点?我的意思是 json 可以是示例中的 json 以外的任何其他内容,但过程应该是相同的。