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

A single token emitted by `JSONTokenParser`.

The structural tokens (`{` `}` `[` `]`) and the literals (`true`, `false`,
`null`) are primitives — the type is the whole value. The three tokens that
carry data — a key, a string, a number — are classes whose `value` field holds
it, so a token is a value you can hold: match it and read `value`, with nothing
shared or overwritten between tokens.

A key or string value that fits within a single fed chunk with no escapes is a
zero-copy view into that chunk. Holding such a token (or its value) keeps the
chunk's bytes in memory until you drop it — extracting one small field from a
large chunk and holding it pins the whole chunk. A view is also not
NUL-terminated, so passing its `cpointer()` to C that expects a C string reads
past the value; use it as a Pony `String`. Strings with escapes, or split across
a chunk boundary, are decoded copies that hold nothing and are NUL-terminated.

```pony
match token
| let k: JSONTokenKey    => // k.value : String
| let s: JSONTokenString => // s.value : String
| let n: JSONTokenNumber => // n.value : (I64 | F64)
| JSONTokenObjectStart   => // ...
end
```


```pony
type JSONToken is
  (JSONTokenObjectStart val | JSONTokenObjectEnd val | JSONTokenArrayStart val | JSONTokenArrayEnd val | JSONTokenTrue val | JSONTokenFalse val | JSONTokenNull val | JSONTokenKey val | JSONTokenString val | JSONTokenNumber val)
```

#### Type Alias For

* ([JSONTokenObjectStart](json-JSONTokenObjectStart.md) val | [JSONTokenObjectEnd](json-JSONTokenObjectEnd.md) val | [JSONTokenArrayStart](json-JSONTokenArrayStart.md) val | [JSONTokenArrayEnd](json-JSONTokenArrayEnd.md) val | [JSONTokenTrue](json-JSONTokenTrue.md) val | [JSONTokenFalse](json-JSONTokenFalse.md) val | [JSONTokenNull](json-JSONTokenNull.md) val | [JSONTokenKey](json-JSONTokenKey.md) val | [JSONTokenString](json-JSONTokenString.md) val | [JSONTokenNumber](json-JSONTokenNumber.md) val)

---

