Proofread and improve the whole class reference
- Document a few more properties and methods - Add more information to many classes - Fix lots of typos and gramar mistakes - Use [code] tags for parameters consistently - Use [b] and [i] tags consistently - Put "Warning:" and "Note:" on their own line to be more visible, and make them always bold - Tweak formatting in code examples to be more readable - Use double quotes consistently - Add more links to third-party technologies
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
Data class wrapper for decoded JSON.
|
||||
</brief_description>
|
||||
<description>
|
||||
Returned by [method JSON.parse], [JSONParseResult] contains decoded JSON or error information if JSON source not successfully parsed. You can check if JSON source was successfully parsed with [code]if json_result.error == OK[/code].
|
||||
Returned by [method JSON.parse], [JSONParseResult] contains the decoded JSON or error information if the JSON source wasn't successfully parsed. You can check if the JSON source was successfully parsed with [code]if json_result.error == OK[/code].
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
@@ -12,22 +12,22 @@
|
||||
</methods>
|
||||
<members>
|
||||
<member name="error" type="int" setter="set_error" getter="get_error" enum="Error">
|
||||
The error type if JSON source was not successfully parsed. See [@GlobalScope] ERR_* constants.
|
||||
The error type if the JSON source was not successfully parsed. See the [@GlobalScope] [code]ERR_*[/code] constants.
|
||||
</member>
|
||||
<member name="error_line" type="int" setter="set_error_line" getter="get_error_line">
|
||||
The line number where the error occurred if JSON source was not successfully parsed.
|
||||
</member>
|
||||
<member name="error_string" type="String" setter="set_error_string" getter="get_error_string">
|
||||
The error message if JSON source was not successfully parsed. See [@GlobalScope] ERR_* constants.
|
||||
The error message if JSON source was not successfully parsed. See the [@GlobalScope] [code]ERR_*[/code] constants.
|
||||
</member>
|
||||
<member name="result" type="Variant" setter="set_result" getter="get_result">
|
||||
A [Variant] containing the parsed JSON. Use typeof() to check if it is what you expect. For example, if JSON source starts with curly braces ([code]{}[/code]) a [Dictionary] will be returned, if JSON source starts with 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]
|
||||
Note that JSON objects do not preserve key order like Godot dictionaries, thus you should not rely on keys being in a certain order if a dictionary is constructed from JSON. In contrast, JSON arrays retain the order of their elements:[/i]
|
||||
A [Variant] containing the parsed JSON. Use [method @GDScript.typeof] or the [code]is[/code] keyword to check if it is what you expect. For example, if the JSON source starts with curly braces ([code]{}[/code]), a [Dictionary] will be returned. If the JSON source starts with braces ([code][][/code]), an [Array] will be returned.
|
||||
[b]Note:[/b] 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.
|
||||
[b]Note:[/b] JSON objects do not preserve key order like Godot dictionaries, thus, you should not rely on keys being in a certain order if a dictionary is constructed from JSON. In contrast, JSON arrays retain the order of their elements:
|
||||
[codeblock]
|
||||
var p = JSON.parse('["hello", "world", "!"]')
|
||||
if typeof(p.result) == TYPE_ARRAY:
|
||||
print(p.result[0]) # prints 'hello'
|
||||
print(p.result[0]) # Prints "hello"
|
||||
else:
|
||||
print("unexpected results")
|
||||
[/codeblock]
|
||||
|
||||
Reference in New Issue
Block a user