Classes | Public Types | Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
Json::Reader Class Reference

Unserialize a JSON document into a Value. More...

#include <json.h>

Classes

class  ErrorInfo
 
struct  StructuredError
 An error tagged with where in the JSON text it was encountered. More...
 
class  Token
 

Public Types

typedef char Char
 
typedef char Char
 

Public Member Functions

std::string getFormatedErrorMessages () const
 Returns a user friendly string that list errors in the parsed document. More...
 
std::string getFormatedErrorMessages () const
 Returns a user friendly string that list errors in the parsed document. More...
 
std::string getFormattedErrorMessages () const
 Returns a user friendly string that list errors in the parsed document. More...
 
std::string getFormattedErrorMessages () const
 Returns a user friendly string that list errors in the parsed document. More...
 
std::vector< StructuredErrorgetStructuredErrors () const
 Returns a vector of structured erros encounted while parsing. More...
 
std::vector< StructuredErrorgetStructuredErrors () const
 Returns a vector of structured errors encountered while parsing. More...
 
bool good () const
 Return whether there are any errors. More...
 
bool good () const
 Return whether there are any errors. More...
 
bool parse (const char *beginDoc, const char *endDoc, Value &root, bool collectComments=true)
 Read a Value from a JSON document. More...
 
bool parse (const char *beginDoc, const char *endDoc, Value &root, bool collectComments=true)
 Read a Value from a JSON document. More...
 
bool parse (const std::string &document, Value &root, bool collectComments=true)
 Read a Value from a JSON document. More...
 
bool parse (const std::string &document, Value &root, bool collectComments=true)
 Read a Value from a JSON document. More...
 
bool parse (std::istream &is, Value &root, bool collectComments=true)
 Parse from input stream. More...
 
bool parse (std::istream &is, Value &root, bool collectComments=true)
 Parse from input stream. More...
 
bool pushError (const Value &value, const std::string &message)
 Add a semantic error message. More...
 
bool pushError (const Value &value, const std::string &message)
 Add a semantic error message. More...
 
bool pushError (const Value &value, const std::string &message, const Value &extra)
 Add a semantic error message with extra context. More...
 
bool pushError (const Value &value, const std::string &message, const Value &extra)
 Add a semantic error message with extra context. More...
 
 Reader ()
 Constructs a Reader allowing all features for parsing. More...
 
 Reader ()
 Constructs a Reader allowing all features for parsing. More...
 
 Reader (const Features &features)
 Constructs a Reader allowing the specified feature set for parsing. More...
 
 Reader (const Features &features)
 Constructs a Reader allowing the specified feature set for parsing. More...
 

Public Attributes

const typedef CharLocation
 

Private Types

typedef std::deque< ErrorInfoErrors
 
typedef std::deque< ErrorInfoErrors
 
typedef std::stack< Value * > Nodes
 
typedef std::stack< Value * > Nodes
 
enum  TokenType {
  tokenEndOfStream = 0, tokenObjectBegin, tokenObjectEnd, tokenArrayBegin,
  tokenArrayEnd, tokenString, tokenNumber, tokenTrue,
  tokenFalse, tokenNull, tokenArraySeparator, tokenMemberSeparator,
  tokenComment, tokenError, tokenEndOfStream = 0, tokenObjectBegin,
  tokenObjectEnd, tokenArrayBegin, tokenArrayEnd, tokenString,
  tokenNumber, tokenTrue, tokenFalse, tokenNull,
  tokenArraySeparator, tokenMemberSeparator, tokenComment, tokenError
}
 
enum  TokenType {
  tokenEndOfStream = 0, tokenObjectBegin, tokenObjectEnd, tokenArrayBegin,
  tokenArrayEnd, tokenString, tokenNumber, tokenTrue,
  tokenFalse, tokenNull, tokenArraySeparator, tokenMemberSeparator,
  tokenComment, tokenError, 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)
 
void addComment (Location begin, Location end, CommentPlacement placement)
 
bool addError (const std::string &message, Token &token, Location extra=0)
 
bool addError (const std::string &message, Token &token, Location extra=0)
 
bool addErrorAndRecover (const std::string &message, Token &token, TokenType skipUntilToken)
 
bool addErrorAndRecover (const std::string &message, Token &token, TokenType skipUntilToken)
 
ValuecurrentValue ()
 
ValuecurrentValue ()
 
bool decodeDouble (Token &token)
 
bool decodeDouble (Token &token)
 
bool decodeDouble (Token &token, Value &decoded)
 
bool decodeDouble (Token &token, Value &decoded)
 
bool decodeNumber (Token &token)
 
bool decodeNumber (Token &token)
 
bool decodeNumber (Token &token, Value &decoded)
 
bool decodeNumber (Token &token, Value &decoded)
 
bool decodeString (Token &token)
 
bool decodeString (Token &token)
 
bool decodeString (Token &token, std::string &decoded)
 
bool decodeString (Token &token, std::string &decoded)
 
bool decodeUnicodeCodePoint (Token &token, Location &current, Location end, unsigned int &unicode)
 
bool decodeUnicodeCodePoint (Token &token, Location &current, Location end, unsigned int &unicode)
 
bool decodeUnicodeEscapeSequence (Token &token, Location &current, Location end, unsigned int &unicode)
 
bool decodeUnicodeEscapeSequence (Token &token, Location &current, Location end, unsigned int &unicode)
 
std::string getLocationLineAndColumn (Location location) const
 
std::string getLocationLineAndColumn (Location location) const
 
void getLocationLineAndColumn (Location location, int &line, int &column) const
 
void getLocationLineAndColumn (Location location, int &line, int &column) const
 
Char getNextChar ()
 
Char getNextChar ()
 
bool match (Location pattern, int patternLength)
 
bool match (Location pattern, int patternLength)
 
bool readArray (Token &token)
 
bool readArray (Token &token)
 
bool readComment ()
 
bool readComment ()
 
bool readCppStyleComment ()
 
bool readCppStyleComment ()
 
bool readCStyleComment ()
 
bool readCStyleComment ()
 
void readNumber ()
 
void readNumber ()
 
bool readObject (Token &token)
 
bool readObject (Token &token)
 
bool readString ()
 
bool readString ()
 
bool readToken (Token &token)
 
bool readToken (Token &token)
 
bool readValue ()
 
bool readValue ()
 
bool recoverFromError (TokenType skipUntilToken)
 
bool recoverFromError (TokenType skipUntilToken)
 
void skipCommentTokens (Token &token)
 
void skipCommentTokens (Token &token)
 
void skipSpaces ()
 
void skipSpaces ()
 
void skipUntilSpace ()
 
void skipUntilSpace ()
 

Private Attributes

Location begin_
 
bool collectComments_
 
std::string commentsBefore_
 
Location current_
 
std::string document_
 
Location end_
 
Errors errors_
 
Features features_
 
ValuelastValue_
 
Location lastValueEnd_
 
Nodes nodes_
 

Detailed Description

Unserialize a JSON document into a Value.

Deprecated:
Use CharReader and CharReaderBuilder.
Deprecated:
Use CharReader and CharReaderBuilder.

Definition at line 1281 of file third_party/bloaty/third_party/protobuf/conformance/third_party/jsoncpp/json.h.

Member Typedef Documentation

◆ Char [1/2]

typedef char Json::Reader::Char

◆ Char [2/2]

typedef char Json::Reader::Char

◆ Errors [1/2]

typedef std::deque<ErrorInfo> Json::Reader::Errors
private

◆ Errors [2/2]

typedef std::deque<ErrorInfo> Json::Reader::Errors
private

◆ Nodes [1/2]

◆ Nodes [2/2]

Member Enumeration Documentation

◆ TokenType [1/2]

Enumerator
tokenEndOfStream 
tokenObjectBegin 
tokenObjectEnd 
tokenArrayBegin 
tokenArrayEnd 
tokenString 
tokenNumber 
tokenTrue 
tokenFalse 
tokenNull 
tokenArraySeparator 
tokenMemberSeparator 
tokenComment 
tokenError 
tokenEndOfStream 
tokenObjectBegin 
tokenObjectEnd 
tokenArrayBegin 
tokenArrayEnd 
tokenString 
tokenNumber 
tokenTrue 
tokenFalse 
tokenNull 
tokenArraySeparator 
tokenMemberSeparator 
tokenComment 
tokenError 

Definition at line 1407 of file third_party/bloaty/third_party/protobuf/conformance/third_party/jsoncpp/json.h.

◆ TokenType [2/2]

Enumerator
tokenEndOfStream 
tokenObjectBegin 
tokenObjectEnd 
tokenArrayBegin 
tokenArrayEnd 
tokenString 
tokenNumber 
tokenTrue 
tokenFalse 
tokenNull 
tokenArraySeparator 
tokenMemberSeparator 
tokenComment 
tokenError 
tokenEndOfStream 
tokenObjectBegin 
tokenObjectEnd 
tokenArrayBegin 
tokenArrayEnd 
tokenString 
tokenNumber 
tokenTrue 
tokenFalse 
tokenNull 
tokenArraySeparator 
tokenMemberSeparator 
tokenComment 
tokenError 

Definition at line 1407 of file third_party/protobuf/conformance/third_party/jsoncpp/json.h.

Constructor & Destructor Documentation

◆ Reader() [1/4]

Json::Reader::Reader ( )

Constructs a Reader allowing all features for parsing.

Definition at line 274 of file bloaty/third_party/protobuf/conformance/third_party/jsoncpp/jsoncpp.cpp.

◆ Reader() [2/4]

Json::Reader::Reader ( const Features features)

Constructs a Reader allowing the specified feature set for parsing.

Definition at line 279 of file bloaty/third_party/protobuf/conformance/third_party/jsoncpp/jsoncpp.cpp.

◆ Reader() [3/4]

Json::Reader::Reader ( )

Constructs a Reader allowing all features for parsing.

◆ Reader() [4/4]

Json::Reader::Reader ( const Features features)

Constructs a Reader allowing the specified feature set for parsing.

Member Function Documentation

◆ addComment() [1/2]

void Json::Reader::addComment ( Location  begin,
Location  end,
CommentPlacement  placement 
)
private

◆ addComment() [2/2]

void Json::Reader::addComment ( Location  begin,
Location  end,
CommentPlacement  placement 
)
private

◆ addError() [1/2]

bool Json::Reader::addError ( const std::string &  message,
Token token,
Location  extra = 0 
)
private

◆ addError() [2/2]

bool Json::Reader::addError ( const std::string &  message,
Token token,
Location  extra = 0 
)
private

◆ addErrorAndRecover() [1/2]

bool Json::Reader::addErrorAndRecover ( const std::string &  message,
Token token,
TokenType  skipUntilToken 
)
private

◆ addErrorAndRecover() [2/2]

bool Json::Reader::addErrorAndRecover ( const std::string &  message,
Token token,
TokenType  skipUntilToken 
)
private

◆ currentValue() [1/2]

Value & Json::Reader::currentValue ( )
private

◆ currentValue() [2/2]

Value& Json::Reader::currentValue ( )
private

◆ decodeDouble() [1/4]

bool Json::Reader::decodeDouble ( Token token)
private

◆ decodeDouble() [2/4]

bool Json::Reader::decodeDouble ( Token token)
private

◆ decodeDouble() [3/4]

bool Json::Reader::decodeDouble ( Token token,
Value decoded 
)
private

◆ decodeDouble() [4/4]

bool Json::Reader::decodeDouble ( Token token,
Value decoded 
)
private

◆ decodeNumber() [1/4]

bool Json::Reader::decodeNumber ( Token token)
private

◆ decodeNumber() [2/4]

bool Json::Reader::decodeNumber ( Token token)
private

◆ decodeNumber() [3/4]

bool Json::Reader::decodeNumber ( Token token,
Value decoded 
)
private

◆ decodeNumber() [4/4]

bool Json::Reader::decodeNumber ( Token token,
Value decoded 
)
private

◆ decodeString() [1/4]

bool Json::Reader::decodeString ( Token token)
private

◆ decodeString() [2/4]

bool Json::Reader::decodeString ( Token token)
private

◆ decodeString() [3/4]

bool Json::Reader::decodeString ( Token token,
std::string &  decoded 
)
private

◆ decodeString() [4/4]

bool Json::Reader::decodeString ( Token token,
std::string &  decoded 
)
private

◆ decodeUnicodeCodePoint() [1/2]

bool Json::Reader::decodeUnicodeCodePoint ( Token token,
Location current,
Location  end,
unsigned int unicode 
)
private

◆ decodeUnicodeCodePoint() [2/2]

bool Json::Reader::decodeUnicodeCodePoint ( Token token,
Location current,
Location  end,
unsigned int unicode 
)
private

◆ decodeUnicodeEscapeSequence() [1/2]

bool Json::Reader::decodeUnicodeEscapeSequence ( Token token,
Location current,
Location  end,
unsigned int unicode 
)
private

◆ decodeUnicodeEscapeSequence() [2/2]

bool Json::Reader::decodeUnicodeEscapeSequence ( Token token,
Location current,
Location  end,
unsigned int unicode 
)
private

◆ getFormatedErrorMessages() [1/2]

std::string Json::Reader::getFormatedErrorMessages ( ) const

Returns a user friendly string that list errors in the parsed document.

Returns
Formatted error message with the list of errors with their location in the parsed document. An empty string is returned if no error occurred during parsing.
Deprecated:
Use getFormattedErrorMessages() instead (typo fix).

◆ getFormatedErrorMessages() [2/2]

std::string Json::Reader::getFormatedErrorMessages ( ) const

Returns a user friendly string that list errors in the parsed document.

Returns
Formatted error message with the list of errors with their location in the parsed document. An empty string is returned if no error occurred during parsing.
Deprecated:
Use getFormattedErrorMessages() instead (typo fix).

Definition at line 1005 of file bloaty/third_party/protobuf/conformance/third_party/jsoncpp/jsoncpp.cpp.

◆ getFormattedErrorMessages() [1/2]

std::string Json::Reader::getFormattedErrorMessages ( ) const

Returns a user friendly string that list errors in the parsed document.

Returns
Formatted error message with the list of errors with their location in the parsed document. An empty string is returned if no error occurred during parsing.

◆ getFormattedErrorMessages() [2/2]

std::string Json::Reader::getFormattedErrorMessages ( ) const

Returns a user friendly string that list errors in the parsed document.

Returns
Formatted error message with the list of errors with their location in the parsed document. An empty string is returned if no error occurred during parsing.

Definition at line 1009 of file bloaty/third_party/protobuf/conformance/third_party/jsoncpp/jsoncpp.cpp.

◆ getLocationLineAndColumn() [1/4]

std::string Json::Reader::getLocationLineAndColumn ( Location  location) const
private

◆ getLocationLineAndColumn() [2/4]

std::string Json::Reader::getLocationLineAndColumn ( Location  location) const
private

◆ getLocationLineAndColumn() [3/4]

void Json::Reader::getLocationLineAndColumn ( Location  location,
int line,
int column 
) const
private

◆ getLocationLineAndColumn() [4/4]

void Json::Reader::getLocationLineAndColumn ( Location  location,
int line,
int column 
) const
private

◆ getNextChar() [1/2]

Char Json::Reader::getNextChar ( )
private

◆ getNextChar() [2/2]

Reader::Char Json::Reader::getNextChar ( )
private

◆ getStructuredErrors() [1/2]

std::vector<StructuredError> Json::Reader::getStructuredErrors ( ) const

Returns a vector of structured errors encountered while parsing.

Returns
A (possibly empty) vector of StructuredError objects. Currently only one error can be returned, but the caller should tolerate multiple errors. This can occur if the parser recovers from a non-fatal parse error and then encounters additional errors.

◆ getStructuredErrors() [2/2]

std::vector< Reader::StructuredError > Json::Reader::getStructuredErrors ( ) const

Returns a vector of structured erros encounted while parsing.

Returns
A (possibly empty) vector of StructuredError objects. Currently only one error can be returned, but the caller should tolerate multiple errors. This can occur if the parser recovers from a non-fatal parse error and then encounters additional errors.

Definition at line 1025 of file bloaty/third_party/protobuf/conformance/third_party/jsoncpp/jsoncpp.cpp.

◆ good() [1/2]

bool Json::Reader::good ( ) const

Return whether there are any errors.

Returns
true if there are no errors to report false if errors have occurred.

Definition at line 1075 of file bloaty/third_party/protobuf/conformance/third_party/jsoncpp/jsoncpp.cpp.

◆ good() [2/2]

bool Json::Reader::good ( ) const

Return whether there are any errors.

Returns
true if there are no errors to report false if errors have occurred.

◆ match() [1/2]

bool Json::Reader::match ( Location  pattern,
int  patternLength 
)
private

◆ match() [2/2]

bool Json::Reader::match ( Location  pattern,
int  patternLength 
)
private

◆ parse() [1/6]

bool Json::Reader::parse ( const char *  beginDoc,
const char *  endDoc,
Value root,
bool  collectComments = true 
)

Read a Value from a JSON document.

Parameters
beginDocPointer on the beginning of the UTF-8 encoded string of the document to read.
endDocPointer 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.
collectCommentstrue to collect comment and allow writing them back during serialization, false to discard comments. This parameter is ignored if Features::allowComments_ is false.
Returns
true if the document was successfully parsed, false if an error occurred.

◆ parse() [2/6]

bool Json::Reader::parse ( const char *  beginDoc,
const char *  endDoc,
Value root,
bool  collectComments = true 
)

Read a Value from a JSON document.

Parameters
beginDocPointer on the beginning of the UTF-8 encoded string of the document to read.
endDocPointer 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.
collectCommentstrue to collect comment and allow writing them back during serialization, false to discard comments. This parameter is ignored if Features::allowComments_ is false.
Returns
true if the document was successfully parsed, false if an error occurred.

Definition at line 305 of file bloaty/third_party/protobuf/conformance/third_party/jsoncpp/jsoncpp.cpp.

◆ parse() [3/6]

bool Json::Reader::parse ( const std::string &  document,
Value root,
bool  collectComments = true 
)

Read a Value from a JSON document.

Parameters
documentUTF-8 encoded string containing the document to read.
root[out] Contains the root value of the document if it was successfully parsed.
collectCommentstrue to collect comment and allow writing them back during serialization, false to discard comments. This parameter is ignored if Features::allowComments_ is false.
Returns
true if the document was successfully parsed, false if an error occurred.

Definition at line 285 of file bloaty/third_party/protobuf/conformance/third_party/jsoncpp/jsoncpp.cpp.

◆ parse() [4/6]

bool Json::Reader::parse ( const std::string &  document,
Value root,
bool  collectComments = true 
)

Read a Value from a JSON document.

Parameters
documentUTF-8 encoded string containing the document to read.
root[out] Contains the root value of the document if it was successfully parsed.
collectCommentstrue to collect comment and allow writing them back during serialization, false to discard comments. This parameter is ignored if Features::allowComments_ is false.
Returns
true if the document was successfully parsed, false if an error occurred.

◆ parse() [5/6]

bool Json::Reader::parse ( std::istream &  is,
Value root,
bool  collectComments = true 
)

Parse from input stream.

See also
Json::operator>>(std::istream&, Json::Value&).

◆ parse() [6/6]

bool Json::Reader::parse ( std::istream &  is,
Value root,
bool  collectComments = true 
)

◆ pushError() [1/4]

bool Json::Reader::pushError ( const Value value,
const std::string &  message 
)

Add a semantic error message.

Parameters
valueJSON Value location associated with the error
messageThe error message.
Returns
true if the error was successfully added, false if the Value offset exceeds the document size.

◆ pushError() [2/4]

bool Json::Reader::pushError ( const Value value,
const std::string &  message 
)

Add a semantic error message.

Parameters
valueJSON Value location associated with the error
messageThe error message.
Returns
true if the error was successfully added, false if the Value offset exceeds the document size.

Definition at line 1040 of file bloaty/third_party/protobuf/conformance/third_party/jsoncpp/jsoncpp.cpp.

◆ pushError() [3/4]

bool Json::Reader::pushError ( const Value value,
const std::string &  message,
const Value extra 
)

Add a semantic error message with extra context.

Parameters
valueJSON Value location associated with the error
messageThe error message.
extraAdditional JSON Value location to contextualize the error
Returns
true if the error was successfully added, false if either Value offset exceeds the document size.

Definition at line 1057 of file bloaty/third_party/protobuf/conformance/third_party/jsoncpp/jsoncpp.cpp.

◆ pushError() [4/4]

bool Json::Reader::pushError ( const Value value,
const std::string &  message,
const Value extra 
)

Add a semantic error message with extra context.

Parameters
valueJSON Value location associated with the error
messageThe error message.
extraAdditional JSON Value location to contextualize the error
Returns
true if the error was successfully added, false if either Value offset exceeds the document size.

◆ readArray() [1/2]

bool Json::Reader::readArray ( Token token)
private

◆ readArray() [2/2]

bool Json::Reader::readArray ( Token token)
private

◆ readComment() [1/2]

bool Json::Reader::readComment ( )
private

◆ readComment() [2/2]

bool Json::Reader::readComment ( )
private

◆ readCppStyleComment() [1/2]

bool Json::Reader::readCppStyleComment ( )
private

◆ readCppStyleComment() [2/2]

bool Json::Reader::readCppStyleComment ( )
private

◆ readCStyleComment() [1/2]

bool Json::Reader::readCStyleComment ( )
private

◆ readCStyleComment() [2/2]

bool Json::Reader::readCStyleComment ( )
private

◆ readNumber() [1/2]

void Json::Reader::readNumber ( )
private

◆ readNumber() [2/2]

void Json::Reader::readNumber ( )
private

◆ readObject() [1/2]

bool Json::Reader::readObject ( Token token)
private

◆ readObject() [2/2]

bool Json::Reader::readObject ( Token token)
private

◆ readString() [1/2]

bool Json::Reader::readString ( )
private

◆ readString() [2/2]

bool Json::Reader::readString ( )
private

◆ readToken() [1/2]

bool Json::Reader::readToken ( Token token)
private

◆ readToken() [2/2]

bool Json::Reader::readToken ( Token token)
private

◆ readValue() [1/2]

bool Json::Reader::readValue ( )
private

◆ readValue() [2/2]

bool Json::Reader::readValue ( )
private

◆ recoverFromError() [1/2]

bool Json::Reader::recoverFromError ( TokenType  skipUntilToken)
private

◆ recoverFromError() [2/2]

bool Json::Reader::recoverFromError ( TokenType  skipUntilToken)
private

◆ skipCommentTokens() [1/2]

void Json::Reader::skipCommentTokens ( Token token)
private

◆ skipCommentTokens() [2/2]

void Json::Reader::skipCommentTokens ( Token token)
private

◆ skipSpaces() [1/2]

void Json::Reader::skipSpaces ( )
private

◆ skipSpaces() [2/2]

void Json::Reader::skipSpaces ( )
private

◆ skipUntilSpace() [1/2]

void Json::Reader::skipUntilSpace ( )
private

◆ skipUntilSpace() [2/2]

void Json::Reader::skipUntilSpace ( )
private

Member Data Documentation

◆ begin_

Location Json::Reader::begin_
private

◆ collectComments_

bool Json::Reader::collectComments_
private

◆ commentsBefore_

std::string Json::Reader::commentsBefore_
private

◆ current_

Location Json::Reader::current_
private

◆ document_

std::string Json::Reader::document_
private

◆ end_

Location Json::Reader::end_
private

◆ errors_

Errors Json::Reader::errors_
private

◆ features_

Features Json::Reader::features_
private

◆ lastValue_

Value * Json::Reader::lastValue_
private

◆ lastValueEnd_

Location Json::Reader::lastValueEnd_
private

◆ Location

const typedef Char * Json::Reader::Location

◆ nodes_

Nodes Json::Reader::nodes_
private

The documentation for this class was generated from the following files:


grpc
Author(s):
autogenerated on Fri May 16 2025 03:03:40