JSON processing in Python: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 7: Line 7:
import json
import json


data = json.loads('{"color":"blue", "size":10}')
data = json.loads('{"color":"blue", "size":10, "details":{"shape":{"texture":"bumpy", "orientation":"vertical"}}}')
print(data.get("color"))
print(data.get("color"))
print(data["color"])
print(data.get("size"))
print(data.get("size"))
print(data["shape"]["texture"])
</syntaxhighlight>
</syntaxhighlight>

Revision as of 07:44, 12 January 2022

External

Internal

Overview

import json

data = json.loads('{"color":"blue", "size":10, "details":{"shape":{"texture":"bumpy", "orientation":"vertical"}}}')
print(data.get("color"))
print(data["color"])
print(data.get("size"))
print(data["shape"]["texture"])