`parse_event_t::object_start` | the parser read `{` and started to process a JSON object | depth of the parent of the JSON object | a JSON value with type discarded
`parse_event_t::key` | the parser read a key of a value in an object | depth of the currently parsed JSON object | a JSON string containing the key
`parse_event_t::object_end` | the parser read `}` and finished processing a JSON object | depth of the parent of the JSON object | the parsed JSON object
`parse_event_t::array_start` | the parser read `[` and started to process a JSON array | depth of the parent of the JSON array | a JSON value with type discarded
`parse_event_t::array_end` | the parser read `]` and finished processing a JSON array | depth of the parent of the JSON array | the parsed JSON array
`parse_event_t::value` | the parser finished reading a JSON value | depth of the value | the parsed JSON value

Discarding a value (i.e., returning `#!cpp false`) has different effects
depending on the context in which function was called:
- Discarded values in structured types are skipped. That is, the parser
will behave as if the discarded value was never read.
- In case a value outside a structured type is skipped, it is replaced
with `null`. This case happens if the top-level element is skipped.
## Parameters
`depth` (in)
: the depth of the recursion during parsing
`event` (in)
: an event of type [`parse_event_t`](parse_event_t.md) indicating the context in
the callback function has been called
`parsed` (in, out)
: the current intermediate parse result; note that
writing to this value has no effect for `parse_event_t::key` events
## Return value
Whether the JSON value which called the function during parsing
should be kept (`#!cpp true`) or not (`#!cpp false`). In the latter case, it is either
skipped completely or replaced by an empty discarded object.
# Example
??? example
The example below demonstrates the `parse()` function with
@@ -322,7 +322,7 @@ The iterators passed to constructor `basic_json(InputIT first, InputIT last)` ar
...
@@ -322,7 +322,7 @@ The iterators passed to constructor `basic_json(InputIT first, InputIT last)` ar
### json.exception.invalid_iterator.202
### json.exception.invalid_iterator.202
In an erase or insert function, the passed iterator @a pos does not belong to the JSON value for which the function was called. It hence does not define a valid position for the deletion/insertion.
In an [erase](../api/basic_json/erase.md) or insert function, the passed iterator `pos` does not belong to the JSON value for which the function was called. It hence does not define a valid position for the deletion/insertion.
!!! failure "Example message"
!!! failure "Example message"
...
@@ -335,7 +335,7 @@ In an erase or insert function, the passed iterator @a pos does not belong to th
...
@@ -335,7 +335,7 @@ In an erase or insert function, the passed iterator @a pos does not belong to th
### json.exception.invalid_iterator.203
### json.exception.invalid_iterator.203
Either iterator passed to function `erase(IteratorType` first, IteratorType last) does not belong to the JSON value from which values shall be erased. It hence does not define a valid range to delete values from.
Either iterator passed to function [`erase(IteratorType first, IteratorType last`)](../api/basic_json/erase.md) does not belong to the JSON value from which values shall be erased. It hence does not define a valid range to delete values from.
!!! failure "Example message"
!!! failure "Example message"
...
@@ -345,7 +345,7 @@ Either iterator passed to function `erase(IteratorType` first, IteratorType last
...
@@ -345,7 +345,7 @@ Either iterator passed to function `erase(IteratorType` first, IteratorType last
### json.exception.invalid_iterator.204
### json.exception.invalid_iterator.204
When an iterator range for a primitive type (number, boolean, or string) is passed to a constructor or an erase function, this range has to be exactly (`begin(),``end()),` because this is the only way the single stored value is expressed. All other ranges are invalid.
When an iterator range for a primitive type (number, boolean, or string) is passed to a constructor or an [erase](../api/basic_json/erase.md) function, this range has to be exactly (`begin(),``end()),` because this is the only way the single stored value is expressed. All other ranges are invalid.
!!! failure "Example message"
!!! failure "Example message"
...
@@ -355,7 +355,7 @@ When an iterator range for a primitive type (number, boolean, or string) is pass
...
@@ -355,7 +355,7 @@ When an iterator range for a primitive type (number, boolean, or string) is pass
### json.exception.invalid_iterator.205
### json.exception.invalid_iterator.205
When an iterator for a primitive type (number, boolean, or string) is passed to an erase function, the iterator has to be the `begin()` iterator, because it is the only way to address the stored value. All other iterators are invalid.
When an iterator for a primitive type (number, boolean, or string) is passed to an [erase](../api/basic_json/erase.md) function, the iterator has to be the `begin()` iterator, because it is the only way to address the stored value. All other iterators are invalid.
!!! failure "Example message"
!!! failure "Example message"
...
@@ -549,7 +549,7 @@ The `value()` member functions can only be executed for certain JSON types.
...
@@ -549,7 +549,7 @@ The `value()` member functions can only be executed for certain JSON types.
### json.exception.type_error.307
### json.exception.type_error.307
The `erase()` member functions can only be executed for certain JSON types.
The [`erase()`](../api/basic_json/erase.md) member functions can only be executed for certain JSON types.