JSON에서 동적으로 객체를 만들 수 있습니까?JSON에서 동적으로 객체 만들기
이 배열의 일부이다 :
values: [{
"$type": "Entrance, DataModel",
"EntranceDeviceData": {
"$type": "DeviceData, DataModel",
"Watchdog": 0,
"Inputs": {
"$type": "Int16[], mscorlib",
"$values": [0, 0]
},
"Outputs": {
"$type": "Int16[], mscorlib",
"$values": [0, 0]
},
"Faults": {
"$type": "Int16[], mscorlib",
"$values": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
},
"StandingCommand": 0
},
"Vehicle": null,
"NextStates": {
"$type": "System.Collections.Generic.List`1[[System.String, mscorlib]], mscorlib",
"$values": ["CarApproachingBarrier"]
},
"Repository": {
"$type": "System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.Object, mscorlib]], mscorlib"
},
"Direction": 0,
"Name": "Entrance",
"Position": "0,0,0,0",
}, {...another object...
}, {...another one...
}
]
이 JSON 두 개체가 다르다. 미리 속성을 알지 않고도 (다른 모든 JSON 개체에 대해) 개체를 만들 수 있습니까? 내가 어떻게 해?
(나는 그게 가능하다고 들었지만 어쩌면 내가 그 사람을 잘 이해하지 못했다).
* 다른 JSON 개체에 대해 * 만들 수 있습니까? – Blender
당신이 가지고있는 것은 _not_ JSON입니다. JSON은 항상 비슷한 모양의 문자열 표현입니다. 가지고있는 것은 객체 리터럴을 통해 만들어진 두 개의 객체입니다. – nnnnnn
필자가 의도 한 바를 설명하려고합니다 (코드를 실제 객체의 일부로 편집했습니다). 데이터에서 배열 객체를 만들어야합니다. 모든 "$ type"개체 ("Entrance, DataModel", "Spot, DataModel", "Exit, DataModel"등등)와 관련된 모든 배열은 "$ type"의 모든 종류를 모른 채 배열을 만들어야합니다. 나 JSON 객체 – user2004403