| Home | Libraries | People | FAQ | More

###### parser::write_some (4 of 4 overloads)

Parse a buffer containing a complete JSON.

<h7> Synopsis </h7>

    std::size_t
    write_some(
        string_view s);

<h7> Description </h7>

This function parses a complete JSON contained in the specified character buffer. Additional characters past the end of the complete JSON are ignored. The function returns the actual number of characters parsed, which may be less than the size of the input. This allows parsing of a buffer containing multiple individual JSONs or containing different protocol data:

<h7> Example </h7>

    parser p;                                       // construct a parser
    size_t n = p.write_some( "[1,2,3] null" );      // parse a complete JSON
    assert( n == 8 );                               // only some characters consumed
    value jv = p.release();                         // take ownership of the value

<h7> Complexity </h7>

Linear in `size`.

<h7> Exception Safety </h7>

Basic guarantee. Calls to `memory_resource::allocate` may throw. Upon error or exception, subsequent calls will fail until `reset` is called to parse a new JSON.

<h7> Return Value </h7>

The number of characters consumed from the buffer.

<h7> Parameters </h7>

Name | Description
--- | ---
`s` | The character string to parse.

<h7> Exceptions </h7>

Type | Thrown On
--- | ---
`system_error` | Thrown on error.