Skip to content

JSONParseLimits

[Source]

Resource bounds for JSONTokenParser over untrusted input.

These bound the parser's own working memory: the container-depth stack, and the single string or number it is part-way through. They do not bound how much a JSONReassembler — or your own notifier — chooses to retain; that memory is the caller's choice, so a raw-notifier consumer that drops the tokens it doesn't need stays flat no matter how large the document.

The default constructor applies conservative limits; raise a specific bound when a trusted source legitimately has a large value or deep nesting, or use unlimited() for fully trusted input.

let parser = JSONTokenParser(notify) // default limits
let parser = JSONTokenParser(notify, JSONParseLimits(where max_depth' = 32))
let parser = JSONTokenParser(notify, JSONParseLimits.unlimited())
class val JSONParseLimits

Constructors

create

[Source]

new val create(
  max_depth': USize val = 1024,
  max_string_len': USize val = 1048576,
  max_number_len': USize val = 256)
: JSONParseLimits val^

Parameters

  • max_depth': USize val = 1024
  • max_string_len': USize val = 1048576
  • max_number_len': USize val = 256

Returns


unlimited

[Source]

No bounds — every limit is set to its maximum. For fully trusted input, such as a whole document already held in memory. This is what JSONParser.parse uses.

new val unlimited()
: JSONParseLimits val^

Returns


Public fields

let max_depth: USize val

[Source]

Maximum container nesting depth. Bounds the parser's frame stack.


let max_string_len: USize val

[Source]

Maximum length, in bytes, of a single string's source text (the bytes between the quotes, before any escapes are decoded).


let max_number_len: USize val

[Source]

Maximum length, in bytes, of a single number's source text.