-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Milestone
Description
We always validate whatever you use, as well as any objects and arrays that are part of the path to it. The idea is, you should never get the wrong value just because something you skipped has an error in it; but there are many errors that won't affect that.
A (partial?) list for documentation of what we do and don't validate for skipped values:
Strings:
- We ALWAYS validate the boundaries of strings (that strings are properly closed, taking into account
\"). This means that even if a string has some invalid stuff inside, we validate enough that they cannot affect anything else. - We ALWAYS validate string characters (newlines and control characters being disallowed).
- We only validate the content of escape characters if you unescape a string (like using
get_string()orunescaped_key()). i.e.\pis not allowed, and\umust be followed by hex digits.
Numbers/Booleans/Null:
- For the purposes of structure, we ALWAYS treat any sequence of non-whitespace (except { } [ ] : and ,) is a single number/boolean/null. This means we'll treat that
-0ab-10 trrrueas two values without a comma between them, whether you actually use the values or not. - We only validate the content of numbers, booleans and null if you actually use them.
Arrays/Objects:
- We ALWAYS validate that objects/arrays are closed before continuing to iterate, even if the objects/arrays are skipped.
- We only check for missing or extra
,or:when you iterate or index an array or object. - We only check that keys are strings when you iterate or index an array or object.
- We only validate remaining
,/:in an array or object if you fully iterate it. - We only validate that the closing
]or}matches the opening one if you fully iterate the object/array.
Document:
- We ALWAYS validate that the JSON is not empty.
- We NEVER check if there is extra JSON after your document.
Metadata
Metadata
Assignees
Labels
No labels