.. Generated automatically by doc/tools/makerst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the JSONParseResult.xml source instead. .. The source is found in doc/classes or modules//doc_classes. .. _class_JSONParseResult: JSONParseResult =============== **Inherits:** :ref:`Reference` **<** :ref:`Object` **Category:** Core Brief Description ----------------- Data class wrapper for decoded JSON. Member Functions ---------------- +--------------------------------+------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_error` **(** **)** const | +--------------------------------+------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_error_line` **(** **)** const | +--------------------------------+------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_error_string` **(** **)** const | +--------------------------------+------------------------------------------------------------------------------------------------------------------------+ | :ref:`Variant` | :ref:`get_result` **(** **)** const | +--------------------------------+------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_error` **(** :ref:`int` error **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_error_line` **(** :ref:`int` error_line **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_error_string` **(** :ref:`String` error_string **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_result` **(** :ref:`Variant` result **)** | +--------------------------------+------------------------------------------------------------------------------------------------------------------------+ Member Variables ---------------- - :ref:`int` **error** - The error type if JSON source was not successfully parsed. See [@Global Scope]ERR_* constants. - :ref:`int` **error_line** - The line number where the error occurred if JSON source was not successfully parsed. - :ref:`String` **error_string** - The error message if JSON source was not successfully parsed. See [@Global Scope]ERR_* constants. - :ref:`Variant` **result** - A [Variant] containing the parsed JSON. Use typeof() to check if it is what you expect. For exemple, if JSON source starts with braces [code]{}[/code] a [Dictionary] will be returned, if JSON source starts with array braces [code][][/code] an [Array] will be returned. [i]Be aware that the JSON specification does not define integer or float types, but only a number type. Therefore, parsing a JSON text will convert all numerical values to float types.[/i] [codeblock] p = JSON.parse('["hello", "world", "!"]') if typeof(p) == TYPE_ARRAY: print(p[0]) # prints 'hello' else: print("unexpected results") [/codeblock] Description ----------- Returned by :ref:`JSON.parse`, :ref:`JSONParseResult` contains decoded JSON or error information if JSON source not successfully parsed. You can check if JSON source was successfully parsed with ``if json_result.error == 0``. Member Function Description --------------------------- .. _class_JSONParseResult_get_error: - :ref:`int` **get_error** **(** **)** const .. _class_JSONParseResult_get_error_line: - :ref:`int` **get_error_line** **(** **)** const .. _class_JSONParseResult_get_error_string: - :ref:`String` **get_error_string** **(** **)** const .. _class_JSONParseResult_get_result: - :ref:`Variant` **get_result** **(** **)** const .. _class_JSONParseResult_set_error: - void **set_error** **(** :ref:`int` error **)** .. _class_JSONParseResult_set_error_line: - void **set_error_line** **(** :ref:`int` error_line **)** .. _class_JSONParseResult_set_error_string: - void **set_error_string** **(** :ref:`String` error_string **)** .. _class_JSONParseResult_set_result: - void **set_result** **(** :ref:`Variant` result **)**