Skip to content

Commit

Permalink
Merge pull request #66120 from RedMser/json-spec-docs
Browse files Browse the repository at this point in the history
Add documentation note about `JSON.parse` not being spec compliant
  • Loading branch information
akien-mga authored Sep 20, 2022
2 parents 160e0a4 + f225bfe commit b809b6d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions doc/classes/JSON.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
[codeblock]
var data = JSON.parse_string(json_string) # Returns null if parsing failed.
[/codeblock]
[b]Note:[/b] Both parse methods do not fully comply with the JSON specification:
- Trailing commas in arrays or objects are ignored, instead of causing a parser error.
- New line and tab characters are accepted in string literals, and are treated like their corresponding escape sequences [code]\n[/code] and [code]\t[/code].
- Numbers are parsed using [method String.to_float] which is generally more lax than the JSON specification.
- Certain errors, such as invalid Unicode sequences, do not cause a parser error. Instead, the string is cleansed and an error is logged to the console.
</description>
<tutorials>
</tutorials>
Expand Down

0 comments on commit b809b6d

Please sign in to comment.