We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5fa26e4 commit b60140eCopy full SHA for b60140e
parsing-json/json-parsing-in-python.py
@@ -74,3 +74,22 @@
74
75
available_products = [p for p in products if p["in_stock"]]
76
print(f"Available: {len(available_products)} products")
77
+
78
+# First, let's create a sample config
79
+config_data = {
80
+ "api_url": "https://api.example.com/v2",
81
+ "timeout": 30,
82
+ "retry_attempts": 3,
83
+ "enable_logging": True
84
+}
85
86
+with open('config.json', 'w') as f:
87
+ json.dump(config_data, f, indent=2)
88
89
+with open('config.json', 'r') as f:
90
+ config = json.load(f)
91
92
+print(f"API URL: {config['api_url']}")
93
+print(f"Timeout: {config['timeout']} seconds")
94
+print(f"Logging: {'Enabled' if config['enable_logging'] else 'Disabled'}")
95
0 commit comments