|
spirit2json
A JSON parser/generator written with boost spirit
|
Contains everything related spirit2json JSON parser/generator. More...
Classes | |
| struct | json_grammar |
| Spirit2 qi grammar for parsing json strings to JSONValue AST representations. More... | |
| class | prettyPrinter |
| Static visitor for pretty printing a JSONValue variant to an std::wostream. More... | |
| class | Exception |
| Baseclass for all exceptions in simple2json. More... | |
| class | ParsingFailed |
| Thrown on parser failure. More... | |
Typedefs | |
| typedef std::nullptr_t | JSONNull |
| Typedef to std::nullptr_t for compilers that support it. Emulate otherwise. | |
| typedef std::wstring | JSONString |
| Typedef to std::wstring. | |
| typedef double | JSONNumber |
| Typedef to double. | |
| typedef bool | JSONBool |
| Typedef to bool. | |
| typedef boost::make_recursive_variant < JSONString, JSONNumber, JSONBool, JSONNull, std::vector < boost::recursive_variant_ > , std::map< JSONString, boost::recursive_variant_ > >::type | JSONValue |
| JSON-AST value type. Used to store the abstract JSON representation generated by the parse function and as the input to the generate and stream generation functionality. | |
| typedef std::vector< JSONValue > | JSONArray |
| JSON-AST array type. A vector storing JSONValue objects. | |
| typedef std::map< JSONString, JSONValue > | JSONObject |
| JSON-AST object type. A map storing string, JSONValue pairs. | |
| typedef JSONObject::value_type | JSONObjectPair |
| Value type for JSONObject. | |
Enumerations | |
| enum | JSONValueTypes { JSON_STRING, JSON_NUMBER, JSON_BOOL, JSON_NULL, JSON_ARRAY, JSON_OBJECT } |
| which() value enumeration enum for all types that can be contained in a JSONValue. More... | |
Functions | |
| JSONValue | parse (JSONString str) |
| Parse a given JSON string and return its JSONValue representation. | |
| JSONString | generate (JSONValue &val) |
| Generate a JSON string representation from a given JSONValue. | |
Contains everything related spirit2json JSON parser/generator.
| typedef std::vector<JSONValue> spirit2json::JSONArray |
| typedef std::map<JSONString, JSONValue> spirit2json::JSONObject |
JSON-AST object type. A map storing string, JSONValue pairs.
Usage:
JSONObject object; object.insert(JSONObjectPair(L"key", "value")); object.insert(JSONObjectPair(L"the answer to life the universe and everything", 42); object.insert(JSONObjectPair(L"an array", JSONArray()); ... wstring json = generate(JSONValue(object)); ... wcout << JSONValue(object) << endl;
| typedef boost::make_recursive_variant< JSONString, JSONNumber, JSONBool, JSONNull, std::vector<boost::recursive_variant_ >, std::map<JSONString, boost::recursive_variant_ > >::type spirit2json::JSONValue |
JSON-AST value type. Used to store the abstract JSON representation generated by the parse function and as the input to the generate and stream generation functionality.
Usage:
which() value enumeration enum for all types that can be contained in a JSONValue.
| JSON_STRING |
JSONValue(JSONString()).which() value. |
| JSON_NUMBER |
JSONValue(JSONNumber(0)).which() value. |
| JSON_BOOL |
JSONValue(JSONBool(false)).which() value. |
| JSON_NULL |
JSONValue(JSONNull()).which() value. |
| JSON_ARRAY |
JSONValue(JSONArray()).which() value. |
| JSON_OBJECT |
JSONValue(JSONObject()).which() value. |
| JSONString spirit2json::generate | ( | JSONValue & | val | ) |
Generate a JSON string representation from a given JSONValue.
| val | JSONValue representation |
| JSONValue spirit2json::parse | ( | JSONString | str | ) |
Parse a given JSON string and return its JSONValue representation.
| str | JSON string |
| ParsingFailed | Parser failure |
1.7.5.1