Unserialize a JSON document into a Value. More...
#include <json.h>
Classes | |
class | ErrorInfo |
class | Token |
Public Types | |
typedef char | Char |
typedef const Char * | Location |
Public Member Functions | |
std::string | getFormatedErrorMessages () const |
Returns a user friendly string that list errors in the parsed document. | |
std::string | getFormattedErrorMessages () const |
Returns a user friendly string that list errors in the parsed document. | |
bool | parse (const std::string &document, Value &root, bool collectComments=true) |
Read a Value from a JSON document. | |
bool | parse (const char *beginDoc, const char *endDoc, Value &root, bool collectComments=true) |
Read a Value from a JSON document. | |
bool | parse (std::istream &is, Value &root, bool collectComments=true) |
Parse from input stream. | |
Reader () | |
Constructs a Reader allowing all features for parsing. | |
Reader (const Features &features) | |
Constructs a Reader allowing the specified feature set for parsing. | |
Private Types | |
typedef std::deque< ErrorInfo > | Errors |
typedef std::stack< Value * > | Nodes |
enum | TokenType { tokenEndOfStream = 0, tokenObjectBegin, tokenObjectEnd, tokenArrayBegin, tokenArrayEnd, tokenString, tokenNumber, tokenTrue, tokenFalse, tokenNull, tokenArraySeparator, tokenMemberSeparator, tokenComment, tokenError } |
Private Member Functions | |
void | addComment (Location begin, Location end, CommentPlacement placement) |
bool | addError (const std::string &message, Token &token, Location extra=0) |
bool | addErrorAndRecover (const std::string &message, Token &token, TokenType skipUntilToken) |
Value & | currentValue () |
bool | decodeDouble (Token &token) |
bool | decodeNumber (Token &token) |
bool | decodeString (Token &token) |
bool | decodeString (Token &token, std::string &decoded) |
bool | decodeUnicodeCodePoint (Token &token, Location ¤t, Location end, unsigned int &unicode) |
bool | decodeUnicodeEscapeSequence (Token &token, Location ¤t, Location end, unsigned int &unicode) |
bool | expectToken (TokenType type, Token &token, const char *message) |
void | getLocationLineAndColumn (Location location, int &line, int &column) const |
std::string | getLocationLineAndColumn (Location location) const |
Char | getNextChar () |
bool | match (Location pattern, int patternLength) |
bool | readArray (Token &token) |
bool | readComment () |
bool | readCppStyleComment () |
bool | readCStyleComment () |
void | readNumber () |
bool | readObject (Token &token) |
bool | readString () |
bool | readToken (Token &token) |
bool | readValue () |
bool | recoverFromError (TokenType skipUntilToken) |
void | skipCommentTokens (Token &token) |
void | skipSpaces () |
void | skipUntilSpace () |
Private Attributes | |
Location | begin_ |
bool | collectComments_ |
std::string | commentsBefore_ |
Location | current_ |
std::string | document_ |
Location | end_ |
Errors | errors_ |
Features | features_ |
Value * | lastValue_ |
Location | lastValueEnd_ |
Nodes | nodes_ |
typedef char Json::Reader::Char |
typedef std::deque<ErrorInfo> Json::Reader::Errors [private] |
typedef const Char* Json::Reader::Location |
typedef std::stack<Value *> Json::Reader::Nodes [private] |
enum Json::Reader::TokenType [private] |
Constructs a Reader allowing all features for parsing.
Definition at line 270 of file jsoncpp.cpp.
Json::Reader::Reader | ( | const Features & | features | ) |
Constructs a Reader allowing the specified feature set for parsing.
Definition at line 276 of file jsoncpp.cpp.
void Json::Reader::addComment | ( | Location | begin, |
Location | end, | ||
CommentPlacement | placement | ||
) | [private] |
Definition at line 567 of file jsoncpp.cpp.
bool Json::Reader::addError | ( | const std::string & | message, |
Token & | token, | ||
Location | extra = 0 |
||
) | [private] |
Definition at line 936 of file jsoncpp.cpp.
bool Json::Reader::addErrorAndRecover | ( | const std::string & | message, |
Token & | token, | ||
TokenType | skipUntilToken | ||
) | [private] |
Definition at line 967 of file jsoncpp.cpp.
Value & Json::Reader::currentValue | ( | ) | [private] |
Definition at line 977 of file jsoncpp.cpp.
bool Json::Reader::decodeDouble | ( | Token & | token | ) | [private] |
Definition at line 796 of file jsoncpp.cpp.
bool Json::Reader::decodeNumber | ( | Token & | token | ) | [private] |
Definition at line 743 of file jsoncpp.cpp.
bool Json::Reader::decodeString | ( | Token & | token | ) | [private] |
Definition at line 823 of file jsoncpp.cpp.
bool Json::Reader::decodeString | ( | Token & | token, |
std::string & | decoded | ||
) | [private] |
Definition at line 834 of file jsoncpp.cpp.
bool Json::Reader::decodeUnicodeCodePoint | ( | Token & | token, |
Location & | current, | ||
Location | end, | ||
unsigned int & | unicode | ||
) | [private] |
Definition at line 880 of file jsoncpp.cpp.
bool Json::Reader::decodeUnicodeEscapeSequence | ( | Token & | token, |
Location & | current, | ||
Location | end, | ||
unsigned int & | unicode | ||
) | [private] |
Definition at line 910 of file jsoncpp.cpp.
bool Json::Reader::expectToken | ( | TokenType | type, |
Token & | token, | ||
const char * | message | ||
) | [private] |
Definition at line 425 of file jsoncpp.cpp.
std::string Json::Reader::getFormatedErrorMessages | ( | ) | const |
Returns a user friendly string that list errors in the parsed document.
Definition at line 1035 of file jsoncpp.cpp.
std::string Json::Reader::getFormattedErrorMessages | ( | ) | const |
Returns a user friendly string that list errors in the parsed document.
Definition at line 1042 of file jsoncpp.cpp.
void Json::Reader::getLocationLineAndColumn | ( | Location | location, |
int & | line, | ||
int & | column | ||
) | const [private] |
Definition at line 993 of file jsoncpp.cpp.
std::string Json::Reader::getLocationLineAndColumn | ( | Location | location | ) | const [private] |
Definition at line 1023 of file jsoncpp.cpp.
Reader::Char Json::Reader::getNextChar | ( | ) | [private] |
Definition at line 984 of file jsoncpp.cpp.
bool Json::Reader::match | ( | Location | pattern, |
int | patternLength | ||
) | [private] |
Definition at line 524 of file jsoncpp.cpp.
bool Json::Reader::parse | ( | const std::string & | document, |
Value & | root, | ||
bool | collectComments = true |
||
) |
Read a Value from a JSON document.
document | UTF-8 encoded string containing the document to read. |
root | [out] Contains the root value of the document if it was successfully parsed. |
collectComments | true to collect comment and allow writing them back during serialization, false to discard comments. This parameter is ignored if Features::allowComments_ is false . |
true
if the document was successfully parsed, false
if an error occurred. Definition at line 283 of file jsoncpp.cpp.
bool Json::Reader::parse | ( | const char * | beginDoc, |
const char * | endDoc, | ||
Value & | root, | ||
bool | collectComments = true |
||
) |
Read a Value from a JSON document.
beginDoc | Pointer on the beginning of the UTF-8 encoded string of the document to read. |
endDoc | Pointer on the end of the UTF-8 encoded string of the document to read. \ Must be >= beginDoc. |
root | [out] Contains the root value of the document if it was successfully parsed. |
collectComments | true to collect comment and allow writing them back during serialization, false to discard comments. This parameter is ignored if Features::allowComments_ is false . |
true
if the document was successfully parsed, false
if an error occurred. Definition at line 312 of file jsoncpp.cpp.
bool Json::Reader::parse | ( | std::istream & | is, |
Value & | root, | ||
bool | collectComments = true |
||
) |
Parse from input stream.
Definition at line 295 of file jsoncpp.cpp.
bool Json::Reader::readArray | ( | Token & | token | ) | [private] |
Definition at line 700 of file jsoncpp.cpp.
bool Json::Reader::readComment | ( | ) | [private] |
Definition at line 539 of file jsoncpp.cpp.
bool Json::Reader::readCppStyleComment | ( | ) | [private] |
Definition at line 600 of file jsoncpp.cpp.
bool Json::Reader::readCStyleComment | ( | ) | [private] |
Definition at line 587 of file jsoncpp.cpp.
void Json::Reader::readNumber | ( | ) | [private] |
Definition at line 613 of file jsoncpp.cpp.
bool Json::Reader::readObject | ( | Token & | token | ) | [private] |
Definition at line 641 of file jsoncpp.cpp.
bool Json::Reader::readString | ( | ) | [private] |
Definition at line 625 of file jsoncpp.cpp.
bool Json::Reader::readToken | ( | Token & | token | ) | [private] |
Definition at line 435 of file jsoncpp.cpp.
bool Json::Reader::readValue | ( | ) | [private] |
Definition at line 356 of file jsoncpp.cpp.
bool Json::Reader::recoverFromError | ( | TokenType | skipUntilToken | ) | [private] |
Definition at line 950 of file jsoncpp.cpp.
void Json::Reader::skipCommentTokens | ( | Token & | token | ) | [private] |
Definition at line 407 of file jsoncpp.cpp.
void Json::Reader::skipSpaces | ( | ) | [private] |
Definition at line 510 of file jsoncpp.cpp.
void Json::Reader::skipUntilSpace | ( | ) | [private] |
Location Json::Reader::begin_ [private] |
bool Json::Reader::collectComments_ [private] |
std::string Json::Reader::commentsBefore_ [private] |
Location Json::Reader::current_ [private] |
std::string Json::Reader::document_ [private] |
Location Json::Reader::end_ [private] |
Errors Json::Reader::errors_ [private] |
Features Json::Reader::features_ [private] |
Value* Json::Reader::lastValue_ [private] |
Location Json::Reader::lastValueEnd_ [private] |
Nodes Json::Reader::nodes_ [private] |