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

Chained navigation wrapper for JSON values.

Wraps a JSONValue and provides safe chained access where
JSONNotFound propagates
through the chain — no exceptions until you extract a typed terminal value.

```pony
let nav = JSONNav(json)
try
  let name = nav("user")("name").as_string()?
  let age = nav("user")("age").as_i64()?
end
```


```pony
class val JSONNav
```

## Constructors

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


Wrap a JSON value for navigation.


```pony
new val create(
  value: JSONValue)
: JSONNav val^
```
#### Parameters

*   value: [JSONValue](json-JSONValue.md)

#### Returns

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

---

## Public Functions

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


Navigate into an object by key or array by index.

If the current value is JSONNotFound, the wrong type, or the key/index
is missing, returns a JSONNotFound-wrapping nav. JSONNotFound propagates
through subsequent navigations.


```pony
fun box apply(
  key_or_index: (String val | USize val))
: JSONNav val
```
#### Parameters

*   key_or_index: ([String](builtin-String.md) val | [USize](builtin-USize.md) val)

#### Returns

* [JSONNav](json-JSONNav.md) val

---

### as_string
<span class="source-link">[[Source]](src/json/json_nav.md#L-0-54)</span>


Extract as String. Raises if not a string or JSONNotFound.


```pony
fun box as_string()
: String val ?
```

#### Returns

* [String](builtin-String.md) val ?

---

### as_i64
<span class="source-link">[[Source]](src/json/json_nav.md#L-0-60)</span>


Extract as I64. Raises if not an integer or JSONNotFound.


```pony
fun box as_i64()
: I64 val ?
```

#### Returns

* [I64](builtin-I64.md) val ?

---

### as_f64
<span class="source-link">[[Source]](src/json/json_nav.md#L-0-66)</span>


Extract as F64. Raises if not a float or JSONNotFound.


```pony
fun box as_f64()
: F64 val ?
```

#### Returns

* [F64](builtin-F64.md) val ?

---

### as_bool
<span class="source-link">[[Source]](src/json/json_nav.md#L-0-72)</span>


Extract as Bool. Raises if not a boolean or JSONNotFound.


```pony
fun box as_bool()
: Bool val ?
```

#### Returns

* [Bool](builtin-Bool.md) val ?

---

### as_null
<span class="source-link">[[Source]](src/json/json_nav.md#L-0-78)</span>


Extract as None (JSON null). Raises if not null or JSONNotFound.


```pony
fun box as_null()
: None val ?
```

#### Returns

* [None](builtin-None.md) val ?

---

### as_object
<span class="source-link">[[Source]](src/json/json_nav.md#L-0-84)</span>


Extract as JSONObject. Raises if not an object or JSONNotFound.


```pony
fun box as_object()
: JSONObject val ?
```

#### Returns

* [JSONObject](json-JSONObject.md) val ?

---

### as_array
<span class="source-link">[[Source]](src/json/json_nav.md#L-0-90)</span>


Extract as JSONArray. Raises if not an array or JSONNotFound.


```pony
fun box as_array()
: JSONArray val ?
```

#### Returns

* [JSONArray](json-JSONArray.md) val ?

---

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


Get the raw value for pattern matching.


```pony
fun box json()
: (JSONValue | JSONNotFound val)
```

#### Returns

* ([JSONValue](json-JSONValue.md) | [JSONNotFound](json-JSONNotFound.md) val)

---

### found
<span class="source-link">[[Source]](src/json/json_nav.md#L-0-103)</span>


Check whether navigation succeeded (value is not JSONNotFound).


```pony
fun box found()
: Bool val
```

#### Returns

* [Bool](builtin-Bool.md) val

---

### size
<span class="source-link">[[Source]](src/json/json_nav.md#L-0-109)</span>


Size of the wrapped collection. Raises if not an object or array.


```pony
fun box size()
: USize val ?
```

#### Returns

* [USize](builtin-USize.md) val ?

---

