# JSONParseLimits
<span class="source-link">[[Source]](src/json/json_parse_limits.md#L-0-1)</span>

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.

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


```pony
class val JSONParseLimits
```

## Constructors

### create
<span class="source-link">[[Source]](src/json/json_parse_limits.md#L-0-32)</span>


```pony
new val create(
  max_depth': USize val = 1024,
  max_string_len': USize val = 1_048_576,
  max_number_len': USize val = 256)
: JSONParseLimits val^
```
#### Parameters

*   max_depth': [USize](builtin-USize.md) val = 1024
*   max_string_len': [USize](builtin-USize.md) val = 1_048_576
*   max_number_len': [USize](builtin-USize.md) val = 256

#### Returns

* [JSONParseLimits](json-JSONParseLimits.md) val^

---

### unlimited
<span class="source-link">[[Source]](src/json/json_parse_limits.md#L-0-41)</span>


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.


```pony
new val unlimited()
: JSONParseLimits val^
```

#### Returns

* [JSONParseLimits](json-JSONParseLimits.md) val^

---

## Public fields

### let max_depth: [USize](builtin-USize.md) val
<span class="source-link">[[Source]](src/json/json_parse_limits.md#L-0-22)</span>

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



---

### let max_string_len: [USize](builtin-USize.md) val
<span class="source-link">[[Source]](src/json/json_parse_limits.md#L-0-24)</span>

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](builtin-USize.md) val
<span class="source-link">[[Source]](src/json/json_parse_limits.md#L-0-29)</span>

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



---

