ADTF  3.18.2
Json Namespace Reference

JSON (JavaScript Object Notation). More...

Classes

class  SecureAllocator
 
class  Features
 Configuration passed to reader and writer. More...
 
class  CharReader
 Interface for reading JSON from a char array. More...
 
class  CharReaderBuilder
 Build a CharReader implementation. More...
 
class  Exception
 Base class for all exceptions we throw. More...
 
class  RuntimeError
 Exceptions which the user cannot easily avoid. More...
 
class  LogicError
 Exceptions thrown by JSON_ASSERT/JSON_FAIL macros. More...
 
class  StaticString
 Lightweight wrapper to tag static string. More...
 
class  Value
 Represents a JSON value. More...
 
class  PathArgument
 Experimental and untested: represents an element of the "path" to access a node. More...
 
class  Path
 Experimental and untested: represents a "path" to access a node. More...
 
class  ValueIteratorBase
 base class for Value iterators. More...
 
class  ValueConstIterator
 const iterator for object and array value. More...
 
class  ValueIterator
 Iterator for object and array value. More...
 
class  StreamWriter
 Usage: More...
 
class  StreamWriterBuilder
 Build a StreamWriter implementation. More...
 

Typedefs

typedef int Int
 
typedef unsigned int UInt
 
typedef int64_t Int64
 
typedef uint64_t UInt64
 
typedef Int64 LargestInt
 
typedef UInt64 LargestUInt
 
typedef unsigned int ArrayIndex
 

Enumerations

enum  ValueType {
  nullValue = 0 , intValue , uintValue , realValue ,
  stringValue , booleanValue , arrayValue , objectValue
}
 Type of the value held by a Value object. More...
 
enum  CommentPlacement { commentBefore = 0 , commentAfterOnSameLine , commentAfter , numberOfCommentPlacement }
 

Functions

template<typename T , typename U >
bool operator== (const SecureAllocator< T > &, const SecureAllocator< U > &)
 
template<typename T , typename U >
bool operator!= (const SecureAllocator< T > &, const SecureAllocator< U > &)
 
class JSONCPP_DEPRECATED ("Use CharReader and CharReaderBuilder instead") JSON_API Reader
 Unserialize a JSON document into a Value. More...
 
bool JSON_API parseFromStream (CharReader::Factory const &, JSONCPP_ISTREAM &, Value *root, std::string *errs)
 Consume entire stream and use its begin/end. More...
 
JSON_API JSONCPP_ISTREAM & operator>> (JSONCPP_ISTREAM &, Value &)
 Read from 'sin' into 'root'. More...
 
JSONCPP_NORETURN void throwRuntimeError (JSONCPP_STRING const &msg)
 used internally
 
JSONCPP_NORETURN void throwLogicError (JSONCPP_STRING const &msg)
 used internally
 
JSONCPP_STRING JSON_API writeString (StreamWriter::Factory const &factory, Value const &root)
 Write into stringstream, then return string, for convenience. More...
 
class JSONCPP_DEPRECATED ("Use StreamWriter instead") JSON_API Writer
 Abstract class for writers. More...
 
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API StyledWriter class JSONCPP_DEPRECATED ("Use StreamWriterBuilder instead") JSON_API StyledStreamWriter
 Outputs a Value in JSON format without formatting (not human friendly). More...
 
JSONCPP_STRING JSON_API valueToString (Int value)
 
JSONCPP_STRING JSON_API valueToString (UInt value)
 
JSONCPP_STRING JSON_API valueToString (LargestInt value)
 
JSONCPP_STRING JSON_API valueToString (LargestUInt value)
 
JSONCPP_STRING JSON_API valueToString (double value)
 
JSONCPP_STRING JSON_API valueToString (bool value)
 
JSONCPP_STRING JSON_API valueToQuotedString (const char *value)
 
JSON_API JSONCPP_OSTREAM & operator<< (JSONCPP_OSTREAM &, const Value &root)
 Output using the StyledStreamWriter. More...
 

Detailed Description

JSON (JavaScript Object Notation).

Enumeration Type Documentation

◆ CommentPlacement

Enumerator
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

numberOfCommentPlacement 

root value)

Definition at line 104 of file value.h.

◆ ValueType

enum ValueType

Type of the value held by a Value object.

Enumerator
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).

Definition at line 93 of file value.h.

Function Documentation

◆ JSONCPP_DEPRECATED() [1/3]

class Json::JSONCPP_DEPRECATED ( "Use CharReader and CharReaderBuilder instead"  )

◆ JSONCPP_DEPRECATED() [2/3]

class Json::JSONCPP_DEPRECATED ( "Use StreamWriter instead"  )

Abstract class for writers.

Deprecated:
Use StreamWriter. (And really, this is an implementation detail.)

Definition at line 71 of file workspace/conan/dev_essential/1.3.3/dw/stable/package/37682420cd166e229516a41c8d6a139a0b13e1e1/include/json/writer.h.

◆ JSONCPP_DEPRECATED() [3/3]

class JSONCPP_DEPRECATED ("Use StreamWriterBuilder instead") JSON_API FastWriter class JSONCPP_DEPRECATED ("Use StreamWriterBuilder instead") JSON_API StyledWriter class Json::JSONCPP_DEPRECATED ( "Use StreamWriterBuilder instead"  )

Outputs a Value in JSON format without formatting (not human friendly).

The JSON document is written in a single line. It is not intended for 'human' consumption, but may be usefull to support feature such as RPC where bandwith is limited.

See also
Reader, Value
Deprecated:
Use StreamWriterBuilder.

Writes a Value in JSON format in a human friendly way.

The rules for line break and indent are as follow:

  • Object value:
    • if empty then print {} without indent and line break
    • if not empty the print '{', line break & indent, print one value per line and then unindent and line break and print '}'.
  • Array value:
    • if empty then print [] without indent and line break
    • if the array contains no object value, empty array or some other value types, and all the values fit on one lines, then print the array on a single line.
    • otherwise, it the values do not fit on one line, or the array contains object or non empty array, then print one value per line.

If the Value have comments then they are outputed according to their CommentPlacement.

See also
Reader, Value, Value::setComment()
Deprecated:
Use StreamWriterBuilder.

Writes a Value in JSON format in a human friendly way, to a stream rather than to a string.

The rules for line break and indent are as follow:

  • Object value:
    • if empty then print {} without indent and line break
    • if not empty the print '{', line break & indent, print one value per line and then unindent and line break and print '}'.
  • Array value:
    • if empty then print [] without indent and line break
    • if the array contains no object value, empty array or some other value types, and all the values fit on one lines, then print the array on a single line.
    • otherwise, it the values do not fit on one line, or the array contains object or non empty array, then print one value per line.

If the Value have comments then they are outputed according to their CommentPlacement.

See also
Reader, Value, Value::setComment()
Deprecated:
Use StreamWriterBuilder.

Definition at line 71 of file workspace/conan/dev_essential/1.3.3/dw/stable/package/37682420cd166e229516a41c8d6a139a0b13e1e1/include/json/writer.h.

◆ operator<<()

JSON_API JSONCPP_OSTREAM& Json::operator<< ( JSONCPP_OSTREAM &  ,
const Value root 
)

Output using the StyledStreamWriter.

See also
Json::operator>>()

◆ operator>>()

JSON_API JSONCPP_ISTREAM& Json::operator>> ( JSONCPP_ISTREAM &  ,
Value  
)

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:

cin >> root["dir"]["file"];
cout << root;
Represents a JSON value.
Definition: value.h:177

Result:

{
"dir": {
    "file": {
    // The input stream JSON would be nested here.
    }
}
}
Exceptions
std::exceptionon parse error.
See also
Json::operator<<()

◆ parseFromStream()

bool JSON_API Json::parseFromStream ( CharReader::Factory const &  ,
JSONCPP_ISTREAM &  ,
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.

◆ writeString()

JSONCPP_STRING JSON_API Json::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.