folly::dynamic

Forward declaration of folly::dynamic used for serializing results.

Synopsis

Declared in <folly/json/dynamic.h>

struct dynamic;

Types

NameDescription
NumericTypeHelper Trait mapping an arithmetic type to the dynamic member it is stored as.
array_range_construct_t Used with the array-range ctor.
const_item_iterator Const iterator over the key-value items of an object.
const_key_iterator Const iterator over the keys of an object.
const_value_iterator Const iterator over the values of an object.
item_iterator Mutable iterator over the key-value items of an object.
json_pointer_resolution_error Error describing why a JSON pointer failed to resolve.
json_pointer_resolved_value A value located by resolving a JSON pointer, with its parent context.
value_iterator Mutable iterator over the values of an object.

Type Aliases

NameDescription
const_iterator Const iterator over array elements.
iterator Mutable iterator over array elements.
resolved_json_pointer The result of resolving a JSON pointer: either the resolved value or a resolution error.
value_type The element type held by a dynamic array.

Enums

NameDescription
Type The set of types a dynamic can hold.
json_pointer_resolution_error_code Reason a JSON pointer failed to resolve against a dynamic.

Member Functions

NameDescription
dynamic [constructor]Constructors
~dynamic [destructor]Destroys the dynamic and any value it holds.
operator= Assignment operators
asBool Type conversion.
asDouble Type conversion.
asInt Type conversion.
asString Type conversion.
at Access sub-field or index.
back Return reference to the last element in an array.
begin Array iteration.
c_str c_str overloads
contains Check if key exists.
count Count by key.
emplace Overwriting emplacement.
empty Tests for emptiness.
end Array iteration.
erase erase overloads
eraseInto Erase one object item and move its key and value into a callback.
find find overloads
getBool getString overloads
getDefault getDefault overloads
getDouble getString overloads
getInt getString overloads
getString getString overloads
get_ptr get_ptr overloads
hash Hash self.
insert insert overloads
isArray Type test.
isBool Type test.
isDouble Type test.
isInt Type test.
isNull Type test.
isNumber Type test.
isObject Type test.
isString Type test.
items Get key-value items of an object.
keys Get the keys of an object.
merge_patch Merge JSON Patch.
operator%= Assigns the remainder of dividing this dynamic by another. methodset Op
operator&= Bitwise-ANDs another dynamic into this one. methodset Op
operator*= Multiplies this dynamic by another. methodset Op
operator++ Increment operators
operator+= Adds another dynamic into this one. methodset Op
operator-- Decrement operators
operator-= Subtracts another dynamic from this one. methodset Op
operator/= Divides this dynamic by another. methodset Op
operator[] Subscript operators
operator^= Bitwise-XORs another dynamic into this one. methodset Op
operator|= Bitwise-ORs another dynamic into this one. methodset Op
pop_back Remove an element from the back of an array.
push_back push_back overloads
reserve Pre-allocate size.
resize Change size.
setDefault setDefault overloads
size Get size.
stringPiece c_str overloads
try_emplace Non-overwriting emplacement.
try_get_ptr try_get_ptr overloads
type The type of this dynamic.
typeName The type of this dynamic as a printable string.
update Merge objects.
update_missing Extends this object with mergeObj1, keeping this object's value on duplicate keys.
values Get the values of an object.

Static Member Functions

NameDescription
array array overloads
array_range array_range overloads
merge Creates a new object with the key/value pairs of both objects, preferring the second object's value on duplicate keys.
merge_diff Compute patch.
object object overloads

Static Data Members

NameDescription
array_range_construct Tag value selecting the array-range constructor.

Friends

NameDescription
folly::TypeErrorException thrown when a dynamic is accessed as the wrong type.
folly::dynamic_viewA mutable view of a dynamic that can extract values without copying.
folly::const_dynamic_view///////////////////////////////////////////////////////////////////
folly::operator<<Streams a dynamic to an output stream.
folly::operator+Adds two dynamics, reusing the left-hand operand's storage.
folly::operator^Bitwise-XORs two dynamics.
folly::operator&Bitwise-ANDs two dynamics.
folly::operator|Bitwise-ORs two dynamics.
folly::operator%Computes the remainder of dividing two dynamics.
folly::operator/Divides two dynamics.
folly::operator*Multiplies two dynamics.
folly::operator-Subtracts two dynamics.
folly::operator+Adds two dynamics.
folly::operator>=Greater-than-or-equal comparison.
folly::operator<=Less-than-or-equal comparison.
folly::operator>Greater-than comparison.
folly::operator<Orders two dynamics.
folly::operator!=Deep inequality comparison.
folly::operator==Deep equality comparison. This will compare all the way down an object or array, and is potentially expensive.

Non-Member Functions

NameDescription
PrintToPrinter for GTest.
benchmarkResultsFromDynamicDeserialize benchmark results from a dynamic value.
compareDynamicWithNestedJsonLike compareJson, but with dynamic instances.
compareDynamicWithToleranceLike compareJsonWithTolerance, but operates directly on the dynamics.
convertToReturn a well-typed representation of a dynamic.
eraseLike erase(vector), since C++20.
erase_ifLike erase_if(vector), erase_if(unordered_map), since C++20.
logConfigToDynamicConvert a LogHandlerConfig object to a folly::dynamic object.
logConfigToDynamicConvert a LogConfig object to a folly::dynamic object.
logConfigToDynamicConvert a LogCategoryConfig object to a folly::dynamic object.
make_dynamic_viewDeleted to prevent viewing a temporary dynamic.
make_dynamic_viewReturns a contextually-correct view for the given dynamic.
make_dynamic_viewReturns a contextually-correct view for the given dynamic.
parseJsonParse a json blob out of a range and produce a dynamic representing it.
parseJsonParse a json blob out of a range and produce a dynamic representing it.
parseJson5Parse an experimental json5 blob and produce a dynamic representing it.
parseJsonWithMetadataParse a json blob, recording parse metadata for each value.
parseJsonWithMetadataParse a json blob with options, recording parse metadata for each value.
parseLogConfigDynamicParse a folly::dynamic object.
toDynamicTurn an arbitrary type into a dynamic.
toJsonSerialize a dynamic into a json string.
toPrettyJsonSerialize a dynamic into a json string with indentation. Note that the keys of all objects will be sorted.
bser::parseBserParse a BSER value from a string with deserialization options.
bser::parseBserParse a BSER value from an IOBuf with deserialization options.
bser::parseBserParse a BSER value from an IOBuf.
bser::parseBserParse a BSER value from a byte range with deserialization options.
bser::parseBserParse a BSER value from a string.
bser::parseBserParse a BSER value from a byte range.
bser::toBserSerialize a dynamic value to a BSER-encoded string.
bser::toBserIOBufSerialize a dynamic value to a BSER-encoded IOBuf.
json::serializeSerialize dynamic to json-string, with options.
jsonschema::makeValidatorMake a validator that can be used to check various json. Thread-safe.