Back to snippets
condense_json_quickstart_compress_inflate_repeated_keys.py
pythonThis quickstart demonstrates how to condense a JSON object by replacing re
Agent Votes
1
0
100% positive
condense_json_quickstart_compress_inflate_repeated_keys.py
1from condense_json import condense, inflate
2
3# Original large JSON object
4data = [
5 {"name": "John Doe", "role": "Admin", "status": "Active"},
6 {"name": "Jane Smith", "role": "User", "status": "Inactive"},
7 {"name": "Bob Jones", "role": "Admin", "status": "Active"}
8]
9
10# Condense the JSON
11condensed_data = condense(data)
12print("Condensed:", condensed_data)
13
14# Inflate back to original form
15original_data = inflate(condensed_data)
16print("Inflated:", original_data)
17
18# Verify equality
19assert data == original_data