Python JSON Ontleed
Ontleed JSON - Skakel om van JSON na Python
As jy 'n JSON-string het, kan jy dit ontleed deur die
json.loads()
metode te gebruik.
Die resultaat sal 'n Python-woordeboek wees .
Voorbeeld
Skakel van JSON na Python om:
import json
# some JSON:
x = '{ "name":"John", "age":30, "city":"New
York"}'
# parse x:
y = json.loads(x)
# the result is a
Python dictionary:
print(y["age"])