Simpleson
Classes | Namespaces | Typedefs | Enumerations | Functions
json.h File Reference

Simpleson header file. More...

#include <cstdlib>
#include <string>
#include <vector>
#include <cstdio>
#include <utility>
#include <stdexcept>
#include <cctype>

Go to the source code of this file.

Classes

class  json::invalid_key
 Exception used for invalid JSON keys. More...
 
class  json::parsing_error
 Exception used when invalid JSON is encountered. More...
 
class  json::reader
 Value reader. More...
 
class  json::kvp_reader
 Class for reading object key value pairs. More...
 
struct  json::parsing::parse_results
 Structure for capturing the results of parsing. More...
 
class  json::jobject
 The class used for manipulating JSON objects and arrays. More...
 
class  json::jobject::entry
 Representation of a value in the object. More...
 
class  json::jobject::const_value
 Represents an entry as a constant value. More...
 
class  json::jobject::const_proxy
 Represents an entry as a constant proxy to the value. More...
 
class  json::jobject::proxy
 A proxy that allows modification of the value. More...
 

Namespaces

namespace  json
 Base namespace for simpleson.
 
namespace  json::parsing
 Namespace used for JSON parsing functions.
 

Typedefs

typedef std::pair< std::string, std::string > json::kvp
 (k)ey (v)alue (p)air
 

Enumerations

enum  json::jtype::jtype {
  json::jtype::jstring , json::jtype::jnumber , json::jtype::jobject , json::jtype::jarray ,
  json::jtype::jbool , json::jtype::jnull , json::jtype::not_valid
}
 Descriptor for the type of JSON data. More...
 

Functions

jtype json::jtype::peek (const char input)
 
jtype json::jtype::detect (const char *input)
 Geven a string, determines the type of value the string contains. More...
 
const char * json::parsing::tlws (const char *start)
 (t)rims (l)eading (w)hite (s)pace More...
 
std::string json::parsing::read_digits (const char *input)
 Reads a set of digits from a string. More...
 
std::string json::parsing::decode_string (const char *input)
 Decodes a string in JSON format. More...
 
std::string json::parsing::encode_string (const char *input)
 Encodes a string in JSON format. More...
 
parse_results json::parsing::parse (const char *input)
 Parses the first value encountered in a JSON string. More...
 
template<typename T >
json::parsing::get_number (const char *input, const char *format)
 Template for reading a numeric value. More...
 
template<typename T >
std::string json::parsing::get_number_string (const T &number, const char *format)
 Converts a number to a string. More...
 
std::vector< std::string > json::parsing::parse_array (const char *input)
 Parses a JSON array. More...
 

Detailed Description

Simpleson header file.

Enumeration Type Documentation

◆ jtype

Descriptor for the type of JSON data.

Enumerator
jstring 

String value.

jnumber 

Number value.

jobject 

JSON object.

jarray 

JSON array.

jbool 

Boolean value.

jnull 

Null value.

not_valid 

Value does not conform to JSON standard.

Function Documentation

◆ detect()

json::jtype::jtype json::jtype::detect ( const char *  input)

Geven a string, determines the type of value the string contains.

Parameters
inputThe string to be tested
Returns
The type of JSON value encountered
Note
The function will only determine the type of the first value encountered in the string.