parse_json()

Parse serialized JSON data from a string.

Examples

example picture for parse_json()
1
2
3
4
5
6
serialized_json = '{"red":255, "green":255, "blue":128}'

def setup():
    data = py5.parse_json(serialized_json)
    py5.fill(data['red'], data['green'], data['blue'])
    py5.rect(10, 10, 80, 80)

Description

Parse serialized JSON data from a string. When reading JSON data from a file, load_json() is the better choice.

The JSON data is parsed using the Python json library with the loads method, and the kwargs parameter is passed along to that method.

Syntax

parse_json(serialized_json: Any, **kwargs: Dict[str, Any]) -> Any

Parameters

  • kwargs: Dict[str, Any] - keyword arguments

  • serialized_json: Any - JSON data object that has been serialized as a string

Updated on September 11, 2021 16:51:34pm UTC