Repository navigation
Expand file tree
/
Copy pathexample.py
More file actions
55 lines (45 loc) · 1.37 KB
/
Copy pathexample.py
File metadata and controls
55 lines (45 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""
JSON Schema Parsing Demonstration (`example.py`).
This module demonstrates parsing JSON schema strings (`json.loads`) and iterating top-level keys.
"""
# =========================================================================
# MODULE IMPORT EXPLANATION & PURPOSE:
# - `from json_processor import JSONProcessor`: Modular JSON engine.
# =========================================================================
try:
from json_tutorial.json_processor import JSONProcessor
except ImportError:
from json_processor import JSONProcessor
RAW_DETAILS_JSON = """
{
"properties": {
"firstName": {
"type": "string",
"fname": "Dilshad"
},
"lastName": {
"type": "string",
"lname": "Abdulla"
},
"age": {
"description": "Age in years",
"type": "integer",
"minimum": 0
}
},
"required": ["firstName", "lastName"]
}
"""
def main() -> None:
"""Run JSON schema dictionary inspection."""
data = JSONProcessor.parse_string(RAW_DETAILS_JSON)
print("Parsed JSON Schema Object:")
print(data)
print("\nProperties Keys:")
for prop in data.get("properties", {}):
print(f" - {prop}")
print("\nTop-Level Key Value Pairs:")
for key, value in data.items():
print(f" {key}: {value}")
if __name__ == "__main__":
main()