Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

The JSON library in Python provides functions for encoding Python objects into JSON strings and decoding JSON strings into Python objects. It allows for easy serialization and de-serialization of data, facilitating data interchange between different systems or programming languages. For example, to encode a Python dictionary into a JSON string, you would use the json.dumps() function, and to decode a JSON string back into a Python dictionary, you would use json.loads(). Here's a simple example:

# Encoding Python dictionary to JSON string
data = {"name": "Johnny", "last_name": "Silverhand", "age": 34, "city": "Night City"}
json_string = json.dumps(data)
print(json_string)

# Decoding JSON string back to Python dictionary
decoded_data = json.loads(json_string)
print(decoded_data)

pipy package → None (python bundle library)

  • No labels