Load JSON from URL

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By fpicoral

How do I load a JSON from an URL? I couldn’t find anything about that in the documentation.

:bust_in_silhouette: Reply From: David Krause
extends CanvasLayer

func _ready():

func _on_Button_pressed():

func _on_HTTPRequest_request_completed( result, response_code, headers, body ):
    var json = JSON.parse(body.get_string_from_utf8())

Thank you! Hope that soon they implement a simpler way, like load_JSON(url).

fpicoral | 2019-01-12 14:34

the problem i could imagine is: that a http request could take a while.
Then you have the problem that this could block the execution of your main thread.
So to me it looks like a common solution you find in nearly every callback based language.

David Krause | 2019-01-12 16:35