parse_json()#

Parse serialized JSON data from a string.

Examples#

example picture for parse_json()
1serialized_json = '{"red":255, "green":255, "blue":128}'
2
3def setup():
4    data = py5.parse_json(serialized_json)
5    py5.fill(data['red'], data['green'], data['blue'])
6    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 March 01, 2022 12:15:01pm UTC