The C++ framework for developing highly scalable, high performance servers on Windows platforms.

JB_Json Namespace Reference

Detailed Description

Json-cpp amalgated source ( It is intented to be used with include <json/json.h>.

JSON (JavaScript Object Notation).


class  Features
class  StaticString
class  Value
class  PathArgument
class  Path
class  ValueIteratorBase
class  ValueConstIterator
class  ValueIterator
class  Reader
class  CharReader
 Interface for reading JSON from a char array. More...
class  CharReaderBuilder
class  StreamWriter
 Usage:. More...
class  StreamWriterBuilder
class  Writer
class  FastWriter
class  StyledWriter
class  StyledStreamWriter


typedef int Int
typedef unsigned int UInt
typedef __int64 Int64
typedef unsigned __int64 UInt64
typedef Int64 LargestInt
typedef UInt64 LargestUInt
typedef unsigned int ArrayIndex
typedef char UIntToStringBuffer [uintToStringBufferSize]
< CharReader
< StreamWriter


enum  ValueType {
  nullValue = 0, intValue, uintValue, realValue,
  stringValue, booleanValue, arrayValue, objectValue
enum  CommentPlacement { commentBefore = 0, commentAfterOnSameLine, commentAfter, numberOfCommentPlacement }
enum  { uintToStringBufferSize = 3 * sizeof(LargestUInt) + 1 }


bool parseFromStream (CharReader::Factory const &, std::istream &, Value *root, std::string *errs)
 Consume entire stream and use its begin/end.
JSON_API std::istream & operator>> (std::istream &, Value &)
std::string writeString (StreamWriter::Factory const &factory, Value const &root)
std::string JSON_API valueToString (Int value)
std::string JSON_API valueToString (UInt value)
std::string JSON_API valueToString (LargestInt value)
std::string JSON_API valueToString (LargestUInt value)
std::string JSON_API valueToString (double value)
std::string JSON_API valueToString (bool value)
std::string JSON_API valueToQuotedString (const char *value)
JSON_API std::ostream & operator<< (std::ostream &, const Value &root)
static std::string codePointToUTF8 (unsigned int cp)
 Converts a unicode code-point to UTF-8.
static bool isControlCharacter (char ch)
 Returns true if ch is a control character (in range [0,32[).
static void uintToString (LargestUInt value, char *&current)
 Converts an unsigned integer to string.
static void fixNumericLocale (char *begin, char *end)
 Change ',' to '.
static bool containsNewLine (Reader::Location begin, Reader::Location end)
static std::string normalizeEOL (Reader::Location begin, Reader::Location end)
static void getValidReaderKeys (std::set< std::string > *valid_keys)
static const
unsigned char 
ALIGNAS (8) kNull[sizeof(Value)]
template<typename T, typename U>
static bool InRange (double d, T min, U max)
static char * duplicateStringValue (const char *value, unsigned int length=unknown)
 Duplicates the specified string value.
static void releaseStringValue (char *value)
 Free the string duplicated by duplicateStringValue().
static bool IsIntegral (double d)
static bool containsControlCharacter (const char *str)
static void getValidWriterKeys (std::set< std::string > *valid_keys)


static const Value null
const unsigned char & kNullRef = kNull[0]
static const double maxUInt64AsDouble = 18446744073709551615.0
static const unsigned int unknown = (unsigned)-1
 Unknown size marker.

Typedef Documentation

typedef unsigned int ArrayIndex

typedef std::unique_ptr<CharReader> CharReaderPtr

typedef int Int

typedef __int64 Int64

typedef Int64 LargestInt

typedef std::unique_ptr<StreamWriter> StreamWriterPtr

typedef unsigned int UInt

typedef unsigned __int64 UInt64

typedef char UIntToStringBuffer[uintToStringBufferSize]

Enumeration Type Documentation

anonymous enum

uintToStringBufferSize  Constant that specify the size of the buffer that must be passed to uintToString.

commentBefore  a comment placed on the line before a value
commentAfterOnSameLine  a comment just after a value on the same line
commentAfter  a comment on the line after a value (only make sense for root value)

enum ValueType

Type of the value held by a Value object.

nullValue  'null' value
intValue  signed integer value
uintValue  unsigned integer value
realValue  double value
stringValue  UTF-8 string value.
booleanValue  bool value
arrayValue  array value (ordered list)
objectValue  object value (collection of name/value pairs).

Function Documentation

static const unsigned char JB_Json::ALIGNAS (  )  [static]

static std::string JB_Json::codePointToUTF8 ( unsigned int  cp  )  [inline, static]

Converts a unicode code-point to UTF-8.

static bool JB_Json::containsControlCharacter ( const char *  str  )  [static]

static bool JB_Json::containsNewLine ( Reader::Location  begin,
Reader::Location  end 
) [static]

static char* JB_Json::duplicateStringValue ( const char *  value,
unsigned int  length = unknown 
) [inline, static]

Duplicates the specified string value.

value Pointer to the string to duplicate. Must be zero-terminated if length is "unknown".
length Length of the value. if equals to unknown, then it will be computed using strlen(value).
Pointer on the duplicate instance of string.

static void JB_Json::fixNumericLocale ( char *  begin,
char *  end 
) [inline, static]

Change ',' to '.

' everywhere in buffer.

We had a sophisticated way, but it did not work in WinCE.

See also:

static void JB_Json::getValidReaderKeys ( std::set< std::string > *  valid_keys  )  [static]

static void JB_Json::getValidWriterKeys ( std::set< std::string > *  valid_keys  )  [static]

static bool JB_Json::InRange ( double  d,
) [inline, static]

static bool JB_Json::isControlCharacter ( char  ch  )  [inline, static]

Returns true if ch is a control character (in range [0,32[).

static bool JB_Json::IsIntegral ( double  d  )  [static]

static std::string JB_Json::normalizeEOL ( Reader::Location  begin,
Reader::Location  end 
) [static]

std::ostream & operator<< ( std::ostream &  sout,
const Value &  root 

Output using the StyledStreamWriter.

See also:

std::istream & operator>> ( std::istream &  sin,
Value &  root 

Read from 'sin' into 'root'.

Always keep comments from the input JSON.

This can be used to read a file into a particular sub-object. For example:

 JB_Json::Value root;
 cin >> root["dir"]["file"];
 cout << root;
 "dir": {
     "file": {
     // The input stream JSON would be nested here.
std::exception on parse error.
See also:

bool parseFromStream ( CharReader::Factory const &  fact,
std::istream &  sin,
Value *  root,
std::string *  errs 

Consume entire stream and use its begin/end.

Someday we might have a real StreamReader, but for now this is convenient.

static void JB_Json::releaseStringValue ( char *  value  )  [inline, static]

Free the string duplicated by duplicateStringValue().

static void JB_Json::uintToString ( LargestUInt  value,
char *&  current 
) [inline, static]

Converts an unsigned integer to string.

value Unsigned interger to convert to string
current Input/Output string buffer. Must have at least uintToStringBufferSize chars free.

std::string valueToQuotedString ( const char *  value  ) 

std::string valueToString ( bool  value  ) 

std::string valueToString ( double  value  ) 

std::string valueToString ( LargestUInt  value  ) 

std::string valueToString ( LargestInt  value  ) 

std::string JSON_API JB_Json::valueToString ( UInt  value  ) 

std::string valueToString ( Int  value  ) 

std::string writeString ( StreamWriter::Factory const &  factory,
Value const &  root 

Write into stringstream, then return string, for convenience. A StreamWriter will be created from the factory, used, and then deleted.

Variable Documentation

const unsigned char& kNullRef = kNull[0]

const double maxUInt64AsDouble = 18446744073709551615.0 [static]

const Value null [static]

const unsigned int unknown = (unsigned)-1 [static]

Unknown size marker.

Generated on Sun Sep 12 19:08:07 2021 for The Server Framework - v7.4 by doxygen 1.5.3