Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
UppHub
Status & Roadmap
FAQ
Authors & License
Forums
Funding U++
Search on this site











SourceForge.net Logo

SourceForge.net Logo

GitHub Logo

Discord Logo

JSON support

 

Value ParseJSON(CParser& p)

Parses JSON represented from p. It is possible to parse only part of whole text (e.g. when to parse just single element of array - parser then stops at the end of element. Elements of JSON are parsed into corresponding Value types, JSON objects are represented by ValueMap, JSON arrays by ValueArray. If input JSON is invalid throws CParser::Error. ParseJSON supports Date/Time using .NET trick as "\/Date(miliseconds_since_1970-1-1)\/".

 


 

Value ParseJSON(const char *s)

Parses JSON text s. Elements of JSON are parsed into corresponding Value types, JSON objects are represented by ValueMap, JSON arrays by ValueArray. If input JSON is invalid returns ErrorValue.

 


 

String AsJSON(int i)

String AsJSON(double n)

String AsJSON(bool b)

String AsJSON(const String& s)

String AsJSON(const WString& s)

String AsJSON(const char *s)

Converts basic values to JSON representation.

 


 

String AsJSON(Time tm)

String AsJSON(Date dt)

Converts Time/Date using .NET trick as "\/Date(miliseconds_since_1970-1-1)\/".

 


 

String AsJSON(const Value& v, const String& indent, bool pretty)

Encodes v as JSON, interpreting ValueMap as JSON object, ValueArray as JSON array. indent is prepended to each line. If pretty is true, JSON is encoded in lines, indenting each level of embedding, if it is false, JSON is as compact as possible.

 


 

String AsJSON(const Value& v, bool pretty = false)

Same as AsJSON(v, String(), pretty).

 

 

Json

 

class Json

Simple helper class intended for composing JSON strings. Json represents JSON object.

 

 

Constructor Detail

 

Json()

Default constructor. Creates empty JSON object.

 


 

Json& CatRaw(const char *key, const String& val)

Appends raw text (which must be a valid JSON) val and key as key-value pair.

 


 

Json(const char *key, const Value& value)

Json(const char *key, int i)

Json(const char *key, double n)

Json(const char *key, bool b)

Json(const char *key, Date d)

Json(const char *key, Time t)

Json(const char *key, const String& s)

Json(const char *key, const WString& s)

Json(const char *key, const char *s)

Json(const char *key, const Json& object)

Json(const char *key, const JsonArray& array)

Construct JSON object with single key-value pair. Date/Time is converted using .NET trick as "\/Date(miliseconds_since_1970-1-1)\/".

 

 

Public Member List

 

String ToString() const

String operator~() const

operator String() const

Returns current JSON formatted text.

 


 

operator bool() const

Returns true if any key-value pairs were added to this JSON object.

 


 

Json& operator()(const char *key, const Value& value)

Json& operator()(const char *key, int i)

Json& operator()(const char *key, double n)

Json& operator()(const char *key, bool b)

Json& operator()(const char *key, Date d)

Json& operator()(const char *key, Time t)

Json& operator()(const char *key, const String& s)

Json& operator()(const char *key, const WString& s)

Json& operator()(const char *key, const char *s)

Json& operator()(const char *key, const Json& object)

Json& operator()(const char *key, const JsonArray& array)

Adds key-value pair to JSON object. Date/Time is converted using .NET trick as "\/Date(miliseconds_since_1970-1-1)\/".

 

 

 

Json

 

class JsonArray

Simple helper class intended for composing JSON strings, representing JSON array.

 

Constructor Detail

 

JsonArray()

Creates empty JSON array.

 

 

Public Member List

 

String ToString() const

String operator~() const

operator String() const

Returns current JSON formatted text.

 


 

operator bool() const

Returns true if there were any elements inserted JSON array.

 


 

JsonArray& CatRaw(const String& val)

Appends raw text (which must be a valid JSON) as an array element.

 


 

JsonArray& operator<<(const Value& value)

JsonArray& operator<<(int i)

JsonArray& operator<<(double n)

JsonArray& operator<<(bool b)

JsonArray& operator<<(Date d)

JsonArray& operator<<(Time t)

JsonArray& operator<<(const String& s)

JsonArray& operator<<(const WString& s)

JsonArray& operator<<(const char *s)

JsonArray& operator<<(const Json& object)

JsonArray& operator<<(const JsonArray& array)

Adds an element to JSON array. Date/Time is converted using .NET trick as "\/Date(miliseconds_since_1970-1-1)\/".

 

 

Do you want to contribute?