| Home | Libraries | People | FAQ | More

###### parser::write (1 of 6 overloads)

Parse a buffer containing a complete JSON text.

###### Synopsis

    std::size_t
    write(
        char const* data,
        std::size_t size,
        error_code& ec);

###### Description

This function parses a complete JSON text contained in the specified character buffer. The entire buffer must be consumed; if there are additional characters past the end of the complete JSON text, the parse fails and an error is returned.

###### Example

    parser p;                                       // construct a parser
    size_t n = p.write( "[1,2,3]" );                // parse a complete JSON text
    assert( n == 7 );                               // all characters consumed
    value jv = p.release();                         // take ownership of the value

###### Complexity

Linear in `size`.

###### Exception Safety

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 text.

###### Return Value

The number of characters consumed from the buffer.

###### Parameters

Name | Description
--- | ---
`data` | A pointer to a buffer of `size` characters to parse.
`size` | The number of characters pointed to by `data`.
`ec` | Set to the error, if any occurred.