|
| UT_JSONValue () |
|
| UT_JSONValue (Type type) |
|
| UT_JSONValue (bool value) |
|
| UT_JSONValue (int64 value) |
|
| UT_JSONValue (fpreal64 value) |
|
| UT_JSONValue (const char *string, int64 length=-1) |
|
| UT_JSONValue (const UT_StringHolder &s) |
|
| UT_JSONValue (const UT_JSONValue &v) |
|
| ~UT_JSONValue () |
|
UT_JSONValue & | operator= (const UT_JSONValue &v) |
|
UT_JSONValue & | operator= (const UT_StringHolder &s) |
|
UT_JSONValue & | operator= (bool v) |
|
UT_JSONValue & | operator= (int64 v) |
|
UT_JSONValue & | operator= (fpreal64 v) |
|
UT_JSONValue | deepCopy () const |
|
bool | parseValue (UT_JSONParser &parser, UT_IStream *is=0, bool record_source_offsets=false) |
|
bool | parseValue (const UT_StringRef &json_source) |
|
bool | parseValue (std::istream &is) |
|
bool | parseValue (UT_IStream &stream) |
|
bool | loadFromFile (const char *file_name, bool record_source_offsets=false) |
| Loads an entire JSON file into this value. More...
|
|
bool | saveToFile (const char *file_name, bool binary=false, UT_CompressionType compressionType=UT_COMPRESSION_TYPE_NONE) |
| Saves an entire JSON value to the specified file. More...
|
|
bool | save (UT_JSONWriter &os) const |
| Save the object the output stream. More...
|
|
void | dump () const |
| Dump the value to stdout (same as save to cout) More...
|
|
UT_StringHolder | toString () const |
|
SYS_NO_DISCARD_RESULT Type | getType () const |
| Get the type of data stored in the object. More...
|
|
SYS_NO_DISCARD_RESULT bool | isMap () const |
|
SYS_NO_DISCARD_RESULT bool | isArray () const |
|
SYS_NO_DISCARD_RESULT bool | isNull () const |
|
SYS_NO_DISCARD_RESULT bool | isValueType () const |
|
SYS_NO_DISCARD_RESULT bool | getB () const |
| Get the bool value. Interprets integer/float as bool. More...
|
|
SYS_NO_DISCARD_RESULT int64 | getI () const |
|
SYS_NO_DISCARD_RESULT fpreal64 | getF () const |
| Get the real value. Interprets bool/int as reals. More...
|
|
SYS_NO_DISCARD_RESULT const
UT_StringHolder & | getString () const |
|
SYS_NO_DISCARD_RESULT const char * | getS () const |
| Get the string value (may return a NULL pointer) More...
|
|
SYS_NO_DISCARD_RESULT int64 | getSLength () const |
| Return the string length (returns -1 if not a string) More...
|
|
SYS_NO_DISCARD_RESULT const
UT_StringHolder * | getStringHolder () const |
| Return the string value. More...
|
|
SYS_NO_DISCARD_RESULT int32 | get (const UT_StringRef &key, int32 def_value) const |
|
SYS_NO_DISCARD_RESULT int64 | get (const UT_StringRef &key, int64 def_value) const |
|
SYS_NO_DISCARD_RESULT
UT_StringHolder | get (const UT_StringRef &key, const UT_StringRef &def_value) const |
|
SYS_NO_DISCARD_RESULT
UT_StringArray | get (const UT_StringRef &key, const UT_StringArray &def_value) const |
|
SYS_NO_DISCARD_RESULT const char * | getKey () const |
| Get a key value. More...
|
|
SYS_NO_DISCARD_RESULT int64 | getKeyLength () const |
| Get the length of the key. More...
|
|
SYS_NO_DISCARD_RESULT const
UT_StringHolder * | getKeyHolder () const |
| Return a string holder for the key. More...
|
|
SYS_NO_DISCARD_RESULT
UT_JSONValueArray * | getArray () const |
| Get the array value (may return a NULL pointer) More...
|
|
SYS_NO_DISCARD_RESULT
UT_JSONValueMap * | getMap () const |
| Get the map value (may return a NULL pointer) More...
|
|
SYS_NO_DISCARD_RESULT Type | getUniformArrayType () const |
|
SYS_FORCE_INLINE bool | import (bool &result) const |
| Extract a bool (returns false if type is invalid) More...
|
|
SYS_FORCE_INLINE bool | import (int64 &result) const |
| Extract an integer (returns false if type is invalid) More...
|
|
SYS_FORCE_INLINE bool | import (fpreal64 &result) const |
| Extract an float (returns false if type is invalid) More...
|
|
bool | import (UT_WorkBuffer &result) const |
| Extract a string or key (returns false if type is invalid) More...
|
|
bool | import (UT_StringHolder &result) const |
|
bool | import (int64 *result, int size) const |
|
bool | import (fpreal64 *result, int size) const |
|
bool | import (UT_Array< int64 > &array) const |
| Extract a vector of integers from a JSON_Array. More...
|
|
bool | import (UT_Array< fpreal64 > &array) const |
| Extract a vector of reals from a JSON_Array. More...
|
|
bool | import (UT_StringArray &array) const |
| Extract a vector of strings from a JSON_Array. More...
|
|
template<typename T > |
bool | import (const UT_StringRef &key, T &reuslt) const |
| Extract a value from the object. Only applies to json objects. More...
|
|
bool | isNumber () const |
| Returns whether the value can be interpreted as a number. More...
|
|
void | setNull () |
| Set value to a null. More...
|
|
void | setBool (bool v) |
| Set value to an bool. More...
|
|
void | setInt (int64 v) |
| Set value to an int. More...
|
|
void | setReal (fpreal64 v) |
| Set value to an int. More...
|
|
void | setString (const char *s, int64 length=-1) |
|
void | setString (const UT_StringHolder &s) |
|
void | setKey (const char *s, int64 length=-1) |
|
void | setKey (const UT_StringHolder &s) |
|
void | setArray (UT_JSONValueArray *array) |
| Set value to the array. More...
|
|
void | setMap (UT_JSONValueMap *map) |
| Set value to the map. More...
|
|
UT_JSONValueArray * | startArray () |
| Start building an array from scratch. More...
|
|
bool | appendArray (const UT_JSONValue &v) |
|
UT_JSONValueMap * | startMap () |
| Start building a map from scratch. More...
|
|
bool | appendMap (const UT_StringHolder &key, const UT_JSONValue &v) |
|
UT_JSONValueMap * | addMapChild (const UT_StringHolder &map_key) |
|
UT_JSONValueArray * | addArrayChild (const UT_StringHolder &map_key) |
|
bool | setAsMap () |
| Set json value as a json map. More...
|
|
bool | setAsArray () |
| Set json value as a json array. More...
|
|
SYS_NO_DISCARD_RESULT int | getMapIndex () const |
| Used internally by UT_JSONValueMap. More...
|
|
void | setMapIndex (int i) |
| Used internally by UT_JSONValueMap. More...
|
|
SYS_NO_DISCARD_RESULT int | getSourceLine () const |
| Used by UT_JSONValue parsing from a stream. More...
|
|
SYS_NO_DISCARD_RESULT int | getSourceOffset () const |
|
void | setSourceOffset (int line, int offset) |
|
SYS_NO_DISCARD_RESULT const
UT_JSONValue * | operator() (int64 i) const |
|
SYS_NO_DISCARD_RESULT
UT_JSONValue * | operator() (int64 i) |
|
SYS_NO_DISCARD_RESULT const
UT_JSONValue * | operator() (const UT_StringRef &k) const |
|
SYS_NO_DISCARD_RESULT
UT_JSONValue * | operator() (const UT_StringRef &k) |
|
SYS_NO_DISCARD_RESULT const
UT_JSONValue & | operator[] (int64 i) const |
|
SYS_NO_DISCARD_RESULT
UT_JSONValue & | operator[] (int64 i) |
|
SYS_NO_DISCARD_RESULT
UT_JSONValue & | operator[] (const UT_StringRef &k) |
|
SYS_NO_DISCARD_RESULT traverser | begin () |
|
SYS_NO_DISCARD_RESULT traverser | end () |
|
SYS_NO_DISCARD_RESULT
const_iterator | begin () const |
|
SYS_NO_DISCARD_RESULT
const_iterator | end () const |
|
SYS_NO_DISCARD_RESULT
const_iterator | cbegin () const |
|
SYS_NO_DISCARD_RESULT
const_iterator | cend () const |
|
SYS_NO_DISCARD_RESULT map_proxy | items () |
|
SYS_NO_DISCARD_RESULT const
map_proxy | items () const |
|
SYS_NO_DISCARD_RESULT indexed_proxy | enumerate () |
|
SYS_NO_DISCARD_RESULT const
indexed_proxy | enumerate () const |
|
SYS_NO_DISCARD_RESULT
indexed_map_proxy | enumerateMap () |
|
SYS_NO_DISCARD_RESULT const
indexed_map_proxy | enumerateMap () const |
|
SYS_NO_DISCARD_RESULT traverser | beginTraversal () |
|
SYS_NO_DISCARD_RESULT exint | count () const |
| Number of elements contained inside the json value. More...
|
|
std::pair< traverser, bool > | insert (const UT_StringHolder &key, const UT_JSONValue &value) |
| Add a key/value pair to the contained map. More...
|
|
template<typename... ARGS> |
std::pair< traverser, bool > | emplace (const UT_StringHolder &key, ARGS &&...args) |
| Add an entry to the contained map. More...
|
|
traverser | append (const UT_JSONValue &v) |
| Insert a json value to the back of the contained array. More...
|
|
template<typename... ARGS> |
traverser | emplace_back (ARGS &&...args) |
| Insert a json value to the back of the contained array. More...
|
|
traverser | find (const UT_StringRef &key) |
|
const_iterator | find (const UT_StringRef &key) const |
|
UT_JSONValue * | get (int64 idx) |
|
const UT_JSONValue * | get (int64 idx) const |
|
UT_JSONValue * | get (const UT_StringRef &k) |
|
const UT_JSONValue * | get (const UT_StringRef &k) const |
|
bool | contains (const UT_StringRef &key) const |
|
void | remove (int64 index) |
|
void | erase (const UT_StringRef &k) |
|
SYS_NO_DISCARD_RESULT
UT_JSONFindResult | findValueRecursive (const UT_StringHolder &map_key, const char *key_value) |
|
SYS_NO_DISCARD_RESULT
UT_JSONFindResult | findParentValueRecursive (const UT_StringHolder &map_key, const char *key_value) |
|
void | removeNullValuesRecursive () |
|
SYS_NO_DISCARD_RESULT SYS_HashType | hash () const |
| Compute a hash. More...
|
|
|
bool | setUniformArray (int nvalues, const int32 *data) |
|
bool | setUniformArray (int nvalues, const int64 *data) |
|
bool | setUniformArray (int nvalues, const fpreal16 *data) |
|
bool | setUniformArray (int nvalues, const fpreal32 *data) |
|
bool | setUniformArray (int nvalues, const fpreal64 *data) |
|
bool | setUniformArray (int nvalues, const UT_StringHolder *data) |
|
|
SYS_NO_DISCARD_RESULT bool | operator== (const UT_JSONValue &src) const |
|
SYS_NO_DISCARD_RESULT bool | operator!= (const UT_JSONValue &src) const |
|
Class to store JSON objects as C++ objects.
This class is able to represent a JSON object in its entirety. Arrays and Maps store arrays and maps of JSON values.
There are methods to load a JSONValue from a UT_JSONParser and to save to a UT_JSONWriter object.
To load an entire JSON file into memory, you can do something like
UT_JSONIStream *is(utistream);
if (!value.load(parser, *is))
To save a value:
UT_JSONWriterSubclass &os;
Alternatively, it's possible to use the UT_JSONValue class from within other UT_JSONHandle classes. For example, when loading key/value pairs for an arbitrary map:
bool
{
if (!value.load(parser))
return false;
process(keyword, value);
return true;
}
- See Also
- UT_JSONParser, UT_JSONWriter, UT_JSONHandle, UT_JSONValueArray, UT_JSONValueMap
- Examples:
- mocapstream/MocapStreamRokokoHDK.C, packedshareddata/GU_PackedSharedData.C, tetprim/GEO_PrimTetra.C, and tetprim/GEO_PrimTetra.h.
Definition at line 99 of file UT_JSONValue.h.