Skip to content

Document precisely what we validate for skipped values #1640

@jkeiser

Description

@jkeiser

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() or unescaped_key()). i.e. \p is not allowed, and \u must 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 trrrue as 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions