Public API Interface for JSON usage. More...


Go to the source code of this file.
Enumerations | |
| enum | LDJSONType { LDNull = 0, LDText, LDNumber, LDBool, LDObject, LDArray } |
| Represents the type of a LaunchDarkly JSON node. More... | |
Functions | |
| struct LDJSON * | LDNewNull (void) |
Constructs a JSON node of type LDJSONNull. More... | |
| struct LDJSON * | LDNewBool (const LDBoolean boolean) |
Constructs a JSON node of type LDJSONBool. More... | |
| struct LDJSON * | LDNewNumber (const double number) |
Constructs a JSON node of type LDJSONumber. More... | |
| struct LDJSON * | LDNewText (const char *const text) |
Returns a new constructed JSON node of type LDJSONText. More... | |
| struct LDJSON * | LDNewObject (void) |
Constructs a JSON node of type LDJSONObject. More... | |
| struct LDJSON * | LDNewArray (void) |
Constructs a JSON node of type LDJSONArray. More... | |
| LDBoolean | LDSetNumber (struct LDJSON *const node, const double number) |
| Set the value of an existing Number. More... | |
| void | LDJSONFree (struct LDJSON *const json) |
| Frees any allocated JSON structure. More... | |
| struct LDJSON * | LDJSONDuplicate (const struct LDJSON *const json) |
| Duplicates an existing JSON structure. This acts as a deep copy. More... | |
| LDJSONType | LDJSONGetType (const struct LDJSON *const json) |
| Get the type of a JSON structure. More... | |
| LDBoolean | LDJSONCompare (const struct LDJSON *const left, const struct LDJSON *const right) |
| Deep compare to check if two JSON structures are equal. More... | |
| LDBoolean | LDGetBool (const struct LDJSON *const node) |
Get the value from a node of type LDJSONBool. More... | |
| double | LDGetNumber (const struct LDJSON *const node) |
Get the value from a node of type LDJSONNumber. More... | |
| const char * | LDGetText (const struct LDJSON *const node) |
Get the value from a node of type LDJSONText. More... | |
| struct LDJSON * | LDIterNext (const struct LDJSON *const iter) |
| Returns the next item in the sequence. More... | |
| struct LDJSON * | LDGetIter (const struct LDJSON *const collection) |
| Allows iteration over an array. Modification of the array invalidates this iterator. More... | |
| const char * | LDIterKey (const struct LDJSON *const iter) |
| Returns the key associated with the iterator Must be an object iterator. More... | |
| unsigned int | LDCollectionGetSize (const struct LDJSON *const collection) |
| Return the size of a JSON collection. More... | |
| struct LDJSON * | LDCollectionDetachIter (struct LDJSON *const collection, struct LDJSON *const iter) |
| Remove an iterator from a collection. More... | |
| struct LDJSON * | LDArrayLookup (const struct LDJSON *const array, const unsigned int index) |
| Lookup up the value of an index for a given array. More... | |
| LDBoolean | LDArrayPush (struct LDJSON *const array, struct LDJSON *const item) |
| Adds an item to the end of an existing array. More... | |
| LDBoolean | LDArrayAppend (struct LDJSON *const prefix, const struct LDJSON *const suffix) |
| Appends the array on the right to the array on the left. More... | |
| struct LDJSON * | LDObjectLookup (const struct LDJSON *const object, const char *const key) |
| Lookup up the value of a key for a given object. More... | |
| LDBoolean | LDObjectSetKey (struct LDJSON *const object, const char *const key, struct LDJSON *const item) |
| Sets the provided key in an object to item. If the key already exists the original value is deleted. More... | |
| void | LDObjectDeleteKey (struct LDJSON *const object, const char *const key) |
| Delete the provided key from the given object. More... | |
| struct LDJSON * | LDObjectDetachKey (struct LDJSON *const object, const char *const key) |
| Detach the provided key from the given object. The returned value is no longer owned by the object and must be manually deleted. More... | |
| LDBoolean | LDObjectMerge (struct LDJSON *const to, const struct LDJSON *const from) |
| Copy keys from one object to another. If a key already exists it is overwritten by the new value. More... | |
| char * | LDJSONSerialize (const struct LDJSON *const json) |
| Serialize JSON structure into JSON text. More... | |
| struct LDJSON * | LDJSONDeserialize (const char *const text) |
| Deserialize JSON text into a JSON structure. More... | |
Public API Interface for JSON usage.
| enum LDJSONType |
| LDBoolean LDArrayAppend | ( | struct LDJSON *const | prefix, |
| const struct LDJSON *const | suffix | ||
| ) |
Appends the array on the right to the array on the left.
| [in] | prefix | Must be of type LDJSONArray. |
| [in] | suffix | Must be of type LDJSONArray. |
| struct LDJSON* LDArrayLookup | ( | const struct LDJSON *const | array, |
| const unsigned int | index | ||
| ) |
Lookup up the value of an index for a given array.
| [in] | array | May not be NULL. must be of type LDJSONArray. |
| [in] | index | The index to lookup in the array |
NULL if does not exist, or on failure. | LDBoolean LDArrayPush | ( | struct LDJSON *const | array, |
| struct LDJSON *const | item | ||
| ) |
Adds an item to the end of an existing array.
| [in] | array | Must be of type LDJSONArray. |
| [in] | item | The value to append to the array. This item is consumed. |
| struct LDJSON* LDCollectionDetachIter | ( | struct LDJSON *const | collection, |
| struct LDJSON *const | iter | ||
| ) |
Remove an iterator from a collection.
| [in] | collection | May not be NULL. must be of type LDJSONArray or LDJSONObject. |
| [in] | iter | May not be NULL. |
NULL on failure. | unsigned int LDCollectionGetSize | ( | const struct LDJSON *const | collection | ) |
Return the size of a JSON collection.
| [in] | collection | May not be NULL. must be of type LDJSONArray or LDJSONObject. |
| LDBoolean LDGetBool | ( | const struct LDJSON *const | node | ) |
Get the value from a node of type LDJSONBool.
| [in] | node | Node to read value from. Must be correct type. |
| struct LDJSON* LDGetIter | ( | const struct LDJSON *const | collection | ) |
Allows iteration over an array. Modification of the array invalidates this iterator.
| [in] | collection | May not be NULL. must be of type LDJSONArray or LDJSONObject. |
NULL if empty or on failure. | double LDGetNumber | ( | const struct LDJSON *const | node | ) |
Get the value from a node of type LDJSONNumber.
| [in] | node | Node to read value from. Must be correct type. |
| const char* LDGetText | ( | const struct LDJSON *const | node | ) |
Get the value from a node of type LDJSONText.
| [in] | node | Node to read value from. Must be correct type. |
NULL on failure. | const char* LDIterKey | ( | const struct LDJSON *const | iter | ) |
Returns the key associated with the iterator Must be an object iterator.
| [in] | iter | The iterator obtained from an object. May not be NULL. |
NULL if there is no key, or on failure. | struct LDJSON* LDIterNext | ( | const struct LDJSON *const | iter | ) |
Returns the next item in the sequence.
| [in] | iter | May be not be NULL (assert) |
NULL if the iterator is finished. | LDBoolean LDJSONCompare | ( | const struct LDJSON *const | left, |
| const struct LDJSON *const | right | ||
| ) |
Deep compare to check if two JSON structures are equal.
| [in] | left | May be NULL. |
| [in] | right | May be NULL. |
| struct LDJSON* LDJSONDeserialize | ( | const char *const | text | ) |
Deserialize JSON text into a JSON structure.
| [in] | text | JSON text to deserialize. May not be NULL. |
NULL on failure. | struct LDJSON* LDJSONDuplicate | ( | const struct LDJSON *const | json | ) |
Duplicates an existing JSON structure. This acts as a deep copy.
| [in] | json | JSON to be duplicated. May not be NULL. |
NULL on failure | void LDJSONFree | ( | struct LDJSON *const | json | ) |
Frees any allocated JSON structure.
| [in] | json | May be NULL. |
| LDJSONType LDJSONGetType | ( | const struct LDJSON *const | json | ) |
Get the type of a JSON structure.
| [in] | json | May be not be NULL. |
LDNull on failure. | char* LDJSONSerialize | ( | const struct LDJSON *const | json | ) |
Serialize JSON structure into JSON text.
| [in] | json | Structure to serialize. May be NULL. |
NULL on failure | struct LDJSON* LDNewArray | ( | void | ) |
Constructs a JSON node of type LDJSONArray.
NULL on failure. | struct LDJSON* LDNewBool | ( | const LDBoolean | boolean | ) |
Constructs a JSON node of type LDJSONBool.
| [in] | boolean | The value to assign the new node |
NULL on failure. | struct LDJSON* LDNewNull | ( | void | ) |
Constructs a JSON node of type LDJSONNull.
NULL on failure. | struct LDJSON* LDNewNumber | ( | const double | number | ) |
Constructs a JSON node of type LDJSONumber.
| [in] | number | The value to assign the new node |
NULL on failure. | struct LDJSON* LDNewObject | ( | void | ) |
Constructs a JSON node of type LDJSONObject.
NULL on failure. | struct LDJSON* LDNewText | ( | const char *const | text | ) |
Returns a new constructed JSON node of type LDJSONText.
| [in] | text | The text to copy and then assign the new node. May not be NULL. |
NULL on failure. | void LDObjectDeleteKey | ( | struct LDJSON *const | object, |
| const char *const | key | ||
| ) |
Delete the provided key from the given object.
| [in] | object | May not be NULL. must be of type LDJSONObject. |
| [in] | key | The key to delete from the object. May not be NULL. |
| struct LDJSON* LDObjectDetachKey | ( | struct LDJSON *const | object, |
| const char *const | key | ||
| ) |
Detach the provided key from the given object. The returned value is no longer owned by the object and must be manually deleted.
| [in] | object | May not be NULL. must be of type LDJSONObject. |
| [in] | key | The key to detach from the object. May not be NULL. |
NULL if it does not exit, or on error. | struct LDJSON* LDObjectLookup | ( | const struct LDJSON *const | object, |
| const char *const | key | ||
| ) |
Lookup up the value of a key for a given object.
| [in] | object | May not be NULL. must be of type LDJSONObject. |
| [in] | key | The key to lookup in the object. May not be NULL. |
NULL. | LDBoolean LDObjectMerge | ( | struct LDJSON *const | to, |
| const struct LDJSON *const | from | ||
| ) |
Copy keys from one object to another. If a key already exists it is overwritten by the new value.
| [in] | to | Object to assign to. May not be NULL. |
| [in] | from | Object to copy keys from. May not be NULL. |
to is polluted on failure. | LDBoolean LDObjectSetKey | ( | struct LDJSON *const | object, |
| const char *const | key, | ||
| struct LDJSON *const | item | ||
| ) |
Sets the provided key in an object to item. If the key already exists the original value is deleted.
| [in] | object | Must be of type LDJSONObject. |
| [in] | key | The key that is being written to in the object. May not be NULL. |
| [in] | item | The value to assign to key. This item is consumed. |
| LDBoolean LDSetNumber | ( | struct LDJSON *const | node, |
| const double | number | ||
| ) |
Set the value of an existing Number.
| [in] | node | The node to set the value of. Must be a number. |
| [in] | number | The value to use for the node. |