Load a JSON data file from a file or URL.


example picture for load_json()
1def setup():
2    data = py5.load_json('colors.json')
3    py5.fill(data['red'], data['green'], data['blue'])
4    py5.rect(10, 10, 80, 80)
 1def setup():
 2    global promise
 3    py5.size(200, 100)
 4    promise = py5.launch_promise_thread(load_data)
 7def load_data():
 8    return py5.load_json('http://py5.ixora.io/files/secret_message.json')
11def draw():
12    py5.background(0)
13    if promise.is_ready:
14        py5.text(promise.result['msg'][:(py5.frame_count // 25)], 20, 50)


Load a JSON data file from a file or URL. When loading a file, the path can be in the data directory, relative to the current working directory (sketch_path()), or an absolute path. When loading from a URL, the json_path parameter must start with http:// or https://.

When loading JSON data from a URL, the data is retrieved using the Python requests library with the get method, and the kwargs parameter is passed along to that method. When loading JSON data from a file, the data is loaded using the Python json library with the load method, and again the kwargs parameter passed along to that method.


load_json(json_path: Union[str, Path], **kwargs: dict[str, Any]) -> Any


  • json_path: Union[str, Path] - url or file path for JSON data file

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

Updated on March 24, 2022 16:35:56pm UTC