JSON function table

jsoncpp mainly consists of three class: Value, Reader, Writer. Note that only processing Json :: Value ANSI string type, if the program is written in C ++ Unicode encoding, it is preferable to add a class adapted Adapt.

 

Json internal classes and methods:

Reader <is used to read and say the exact point, it is used to convert the string to Json :: Value object>

Constructor] [
1, Reader ();
[copy constructor]
2, Reader (const Features & features );
[character string or the input stream into a JSON Value object]
[parse the corresponding lower overloaded function]
3 , BOOL the parse (const String & Document :: STD, the Value & the root, BOOL = collectComments to true);
. 4, the parse BOOL (BeginDoc const char *, const char * EndDoc,

Value &root,bool collectComments = true

5、bool parse( std::istream &is,Value &root,bool collectComments = true );
6、std::string getFormatedErrorMessages() const;

Value: <jsoncpp is the most basic and important class used to represent various types of objects, object types supported jsoncpp visible Json :: ValueType enumerated values; Value class object represents a JSON value may represent either a document, the document may also represent a value. As defined in the JSON "value" as, Value recursive>

[Constructor]
. 1, the Value (the ValueType type = The nullValue);
the Value (Int value);
the Value (UInt value);
the Value (Double value);
the Value (const char * value);
the Value (const char * beginValue, const char * the endValue);
[copy constructor]
2, the value (const StaticString & value);
the value (const STD :: String & value);
the value (const the value & OTHER);
[same type of comparison, the exchange, the type of acquired]
3, void swap (the Value & OTHER);
the ValueType type () const;
int Compare (const the Value & OTHER);
[corresponding assignment operator overloads]
. 4, the Value & operator = (const the Value & OTHER);
BOOL operator <(const the Value & OTHER) const ;
BOOL operator <= (const OTHER the Value &) const;
bool operator >=( const Value &other ) const;
bool operator >( const Value &other ) const;
bool operator ==( const Value &other ) const;
bool operator !=( const Value &other ) const;
bool operator!() const;
Value &operator[]( UInt index );
const Value &operator[]( UInt index ) const;
【将Value对象进行相应的类型转换】
5、const char *asCString() const;
std::string asString() const;
const char *asCString() const;
std::string asString() const;
Int asInt() const;
UInt asUInt() const;
double asDouble() const;
【相应的判断函数】
6、bool isNull() const;
bool isBool() const;
bool isInt() const;
bool isUInt() const;
bool isIntegral() const;
bool isDouble() const;
bool isNumeric() const;
bool isString() const;
bool isArray() const;
bool isObject() const;
bool isConvertibleTo( ValueType other ) const;
bool isValidIndex( UInt index ) const;
bool isMember( const char *key ) const;
bool isMember( const std::string &key ) const;
【清除和扩容函数】
7、void clear();
void resize( UInt size );
【获取满足相应条件的Value】
8、Value get( UInt index, const Value &defaultValue ) const;
Value get( const std::string &key,const Value &defaultValue ) const;
Members getMemberNames() const;
【删除满足相应条件的Value】
9、Value removeMember( const char* key );
Value removeMember( const std::string &key );
10、void setComment( const char *comment,CommentPlacement placement );
void setComment( const std::string &comment,CommentPlacement placement );
bool hasComment( CommentPlacement placement ) const;
std::string getComment( CommentPlacement placement ) const;
std::string toStyledString()const;

Writer: <class is a pure virtual class, and can not be used directly. Here we use Json :: Writer subclass (derived classes):
Json :: FastWriter, Json :: StyledWriter, Json :: StyledStreamWriter. As the name suggests, to deal with json should be the fastest with Json :: FastWriter; responsible for converting Value-memory objects to JSON documents,

Is output to a file or string>

【FastWriter】
1、FastWriter();
virtual ~FastWriter(){}
void enableYAMLCompatibility();
virtual std::string write( const Value &root );
【StyledWriter】
2、StyledWriter();
virtual ~StyledWriter(){}
virtual std::string write( const Value &root );

Guess you like

Origin www.cnblogs.com/gd-luojialin/p/10962885.html