102 |
102 |
103 size_t cxJsonArrSize(const CxJsonValue *value); |
103 size_t cxJsonArrSize(const CxJsonValue *value); |
104 |
104 |
105 CxJsonValue *cxJsonArrGet(const CxJsonValue *value, size_t index); |
105 CxJsonValue *cxJsonArrGet(const CxJsonValue *value, size_t index); |
106 |
106 |
|
107 CxJsonValue *cxJsonArrRemove(const CxJsonValue *value, size_t index); |
|
108 |
107 CxJsonValue *cxJsonObjGet(const CxJsonValue *value, AnyStr name); |
109 CxJsonValue *cxJsonObjGet(const CxJsonValue *value, AnyStr name); |
|
110 |
|
111 CxJsonValue *cxJsonObjRemove(const CxJsonValue *value, AnyStr name); |
108 |
112 |
109 CxIterator cxJsonArrIter(const CxJsonValue *value); |
113 CxIterator cxJsonArrIter(const CxJsonValue *value); |
110 |
114 |
111 CxIterator cxJsonObjIter(const CxJsonValue *value); |
115 CxIterator cxJsonObjIter(const CxJsonValue *value); |
112 ``` |
116 ``` |
130 The functions `cxJsonAsInteger()` and `cxJsonAsDouble()` can be used for any number value. |
134 The functions `cxJsonAsInteger()` and `cxJsonAsDouble()` can be used for any number value. |
131 For example, if `cxJsonAsInteger()` is used on a non-integral number, a double-to-int conversion is performed. |
135 For example, if `cxJsonAsInteger()` is used on a non-integral number, a double-to-int conversion is performed. |
132 |
136 |
133 The function `cxJsonArraySize()` returns the number of items in an array value, |
137 The function `cxJsonArraySize()` returns the number of items in an array value, |
134 which can be accessed via index with `cxJsonArrGet()` or via an iterator created with `cxJsonArrIter()`. |
138 which can be accessed via index with `cxJsonArrGet()` or via an iterator created with `cxJsonArrIter()`. |
135 |
139 An element can be removed from an array with `cxJsonArrRemove()`. |
136 The function `cxJsonObjGet()` returns the member in a JSON object associated with the specified `name`. |
140 |
|
141 The function `cxJsonObjGet()` returns the member in a JSON object associated with the specified `name`. |
|
142 To remove a member, use `cxJsonObjRemove()`. |
137 |
143 |
138 > Both `cxJsonArrGet()` and `cxJsonObjGet()` are safe regarding access to non-existing values. |
144 > Both `cxJsonArrGet()` and `cxJsonObjGet()` are safe regarding access to non-existing values. |
139 > |
145 > |
140 > When `cxJsonArrGet()` is used with an out-of-bounds index, or `cxJsonObjGet()` is used with a non-existent name, |
146 > When `cxJsonArrGet()` is used with an out-of-bounds index, or `cxJsonObjGet()` is used with a non-existent name, |
141 > they return a JSON value, that returns `false` for any `cxJsonIsXYZ()` function. |
147 > they return a JSON value, that returns `false` for any `cxJsonIsXYZ()` function. |
|
148 > |
|
149 > This is **not** the case for `cxJsonArrRemove()` and `cxJsonObjRemove()`, which return `NULL` in that case. |
142 |
150 |
143 > If you don't have full control over the JSON data, you should always check the datatype of a value first, before accessing it. |
151 > If you don't have full control over the JSON data, you should always check the datatype of a value first, before accessing it. |
144 >{style="note"} |
152 >{style="note"} |
145 |
153 |
146 ## Deallocate Memory |
154 ## Deallocate Memory |