millijson
Lightweight JSON parser for C++
|
A lightweight header-only JSON parser. More...
Classes | |
struct | Array |
JSON array. More... | |
struct | Base |
Virtual base class for all JSON types. More... | |
struct | Boolean |
JSON boolean. More... | |
struct | Nothing |
JSON null. More... | |
struct | Number |
JSON number. More... | |
struct | Object |
JSON object. More... | |
struct | String |
JSON string. More... | |
Enumerations | |
enum | Type { NUMBER , STRING , BOOLEAN , NOTHING , ARRAY , OBJECT } |
Functions | |
template<class Input > | |
std::shared_ptr< Base > | parse (Input &input) |
template<class Input > | |
Type | validate (Input &input) |
std::shared_ptr< Base > | parse_string (const char *ptr, size_t len) |
Type | validate_string (const char *ptr, size_t len) |
std::shared_ptr< Base > | parse_file (const char *path, size_t buffer_size=65536) |
Type | validate_file (const char *path, size_t buffer_size=65536) |
A lightweight header-only JSON parser.
enum millijson::Type |
All known JSON types.
std::shared_ptr< Base > millijson::parse | ( | Input & | input | ) |
Input | Any class that provides the following methods: |
char get() const
, which extracts a char
from the input source without advancing the position on the byte stream.bool valid() const
, to determine whether an input char
can be get()
from the input.bool advance()
, to advance the input stream and return valid()
at the new position.size_t position() const
, for the current position relative to the start of the byte stream.input | An instance of an Input class, referring to the bytes from a JSON-formatted file or string. |
|
inline |
[in] | path | Pointer to an array containing a path to a JSON file. |
buffer_size | Size of the buffer to use for reading the file. |
|
inline |
[in] | ptr | Pointer to an array containing a JSON string. |
len | Length of the array. |
Type millijson::validate | ( | Input & | input | ) |
Input | Any class that supplies input characters, see parse() for details. |
input | An instance of an Input class, referring to the bytes from a JSON-formatted file or string. |
input
. If the JSON string is invalid, an error is raised.
|
inline |
[in] | path | Pointer to an array containing a path to a JSON file. |
buffer_size | Size of the buffer to use for reading the file. |
|
inline |
[in] | ptr | Pointer to an array containing a JSON string. |
len | Length of the array. |