sajson
High-Performance JSON Parser
Classes | Enumerations | Functions
sajson Namespace Reference

sajson Public API More...

Classes

class  bounded_allocation
 Allocation policy that attempts to fit the parsed AST into an existing memory buffer. More...
 
class  document
 Represents the result of a JSON parse: either is_valid() and the document contains a root value or parse error information is available. More...
 
class  dynamic_allocation
 Allocation policy that uses dynamically-growing buffers for both the parse stack and the AST. More...
 
class  literal
 A convenient way to parse JSON from a string literal. More...
 
class  mutable_string_view
 A pointer to a mutable buffer, its size in bytes, and strong ownership of any copied memory. More...
 
class  single_allocation
 Allocation policy that allocates one large buffer guaranteed to hold the resulting AST. More...
 
class  string
 A simple type encoding a pointer to some memory and a length (in bytes). More...
 
class  value
 Represents a JSON value. More...
 

Enumerations

enum  type : uint8_t {
  TYPE_INTEGER = 0, TYPE_DOUBLE = 1, TYPE_NULL = 2, TYPE_FALSE = 3,
  TYPE_TRUE = 4, TYPE_STRING = 5, TYPE_ARRAY = 6, TYPE_OBJECT = 7
}
 Tag indicating a JSON value's type. More...
 
enum  error {
  ERROR_SUCCESS, ERROR_OUT_OF_MEMORY, ERROR_UNEXPECTED_END, ERROR_MISSING_ROOT_ELEMENT,
  ERROR_BAD_ROOT, ERROR_EXPECTED_COMMA, ERROR_MISSING_OBJECT_KEY, ERROR_EXPECTED_COLON,
  ERROR_EXPECTED_END_OF_INPUT, ERROR_UNEXPECTED_COMMA, ERROR_EXPECTED_VALUE, ERROR_EXPECTED_NULL,
  ERROR_EXPECTED_FALSE, ERROR_EXPECTED_TRUE, ERROR_INVALID_NUMBER, ERROR_MISSING_EXPONENT,
  ERROR_ILLEGAL_CODEPOINT, ERROR_INVALID_UNICODE_ESCAPE, ERROR_UNEXPECTED_END_OF_UTF16, ERROR_EXPECTED_U,
  ERROR_INVALID_UTF16_TRAIL_SURROGATE, ERROR_UNKNOWN_ESCAPE, ERROR_INVALID_UTF8
}
 Error code indicating why parse failed. More...
 

Functions

template<typename AllocationStrategy , typename StringType >
document parse (const AllocationStrategy &strategy, const StringType &string)
 Parses a string of JSON bytes into a document, given an allocation strategy instance. More...
 

Detailed Description

sajson Public API

Enumeration Type Documentation

enum sajson::type : uint8_t

Tag indicating a JSON value's type.

Error code indicating why parse failed.

Function Documentation

template<typename AllocationStrategy , typename StringType >
document sajson::parse ( const AllocationStrategy &  strategy,
const StringType &  string 
)

Parses a string of JSON bytes into a document, given an allocation strategy instance.

Any kind of string type is valid as long as a mutable_string_view can be constructed from it.

Valid allocation strategies are single_allocation, dynamic_allocation, and bounded_allocation.

A document is returned whether or not the parse succeeds: success state is available by calling document::is_valid().