docs/Writerside/topics/json.h.md

changeset 1424
563033aa998c
parent 1339
bff0a078523d
equal deleted inserted replaced
1423:9a72258446cd 1424:563033aa998c
27 specifying the allocator that shall be used for allocating values of type `CxJsonValue`. 27 specifying the allocator that shall be used for allocating values of type `CxJsonValue`.
28 28
29 Specifying `NULL` as `allocator` is allowed, in which case the `cxDefaultAllocator` will be used. 29 Specifying `NULL` as `allocator` is allowed, in which case the `cxDefaultAllocator` will be used.
30 30
31 The actual parsing is an interleaving invocation of the `cxJsonFill()` (or `cxJsonFilln()`) and `cxJsonNext()` functions. 31 The actual parsing is an interleaving invocation of the `cxJsonFill()` (or `cxJsonFilln()`) and `cxJsonNext()` functions.
32 The `cxJsonFill()` function is a convenience function, that accepts UCX strings and normal zero-terminated C strings. 32 The `cxJsonFill()` function is a convenience function that accepts UCX strings and normal zero-terminated C strings.
33 33
34 Calling `cxJsonNext()` will return with `CX_JSON_NO_ERROR` (= zero) for each JSON value that is successfully parsed, 34 Calling `cxJsonNext()` will return with `CX_JSON_NO_ERROR` (= zero) for each JSON value that is successfully parsed,
35 and stores the pointer to the allocated value in the variable pointed to by `value`. 35 and stores the pointer to the allocated value in the variable pointed to by `value`.
36 36
37 > The parser is capable of parsing multiple consecutive JSON values. 37 > The parser is capable of parsing multiple consecutive JSON values.
115 CxIterator cxJsonObjIter(const CxJsonValue *value); 115 CxIterator cxJsonObjIter(const CxJsonValue *value);
116 ``` 116 ```
117 117
118 The `cxJsonIsXYZ()` family functions check the type of the specified JSON value. 118 The `cxJsonIsXYZ()` family functions check the type of the specified JSON value.
119 119
120 The JSON specification only defines numbers, therefore `cxJsonIsNumber()` returns true for both floating point and integer numbers. 120 The JSON specification only defines numbers, therefore `cxJsonIsNumber()` returns true for both floating-point and integer numbers.
121 On the other hand, `cxJsonIsInteger()` only returns true for integral numbers. 121 On the other hand, `cxJsonIsInteger()` only returns true for integral numbers.
122 122
123 The function `cxJsonIsBool()` returns true if `cxJsonIsLiteral()` returns true, but `cxJsonIsNull()` does not. 123 The function `cxJsonIsBool()` returns true if `cxJsonIsLiteral()` returns true, but `cxJsonIsNull()` does not.
124 124
125 > Since a literal can be `true`, `false`, or `null`, note carefully that `!cxJsonIsTrue(v)` 125 > Since a literal can be `true`, `false`, or `null`, note carefully that `!cxJsonIsTrue(v)`
126 > is in general _not_ equivalent to `cxJsonIsFalse(v)`. 126 > is in general _not_ equivalent to `cxJsonIsFalse(v)`.
127 > 127 >
128 > Additionally, UCX does implement the Javascript concept of a "falsy" value, meaning that 128 > Additionally, UCX does implement the JavaScript concept of a "falsy" value, meaning that
129 > `cxJsonIsFalse()` _only_ returns true, if the value is a literal `false`. 129 > `cxJsonIsFalse()` _only_ returns true, if the value is a literal `false`.
130 >{style="note"} 130 >{style="note"}
131 131
132 The `cxJsonAsXYZ()` family of functions return the value with its corresponding C type. 132 The `cxJsonAsXYZ()` family of functions return the value with its corresponding C type.
133 133
146 > 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,
147 > 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 > 148 >
149 > This is **not** the case for `cxJsonArrRemove()` and `cxJsonObjRemove()`, which return `NULL` in that case. 149 > This is **not** the case for `cxJsonArrRemove()` and `cxJsonObjRemove()`, which return `NULL` in that case.
150 150
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. 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.
152 >{style="note"} 152 >{style="note"}
153 153
154 ## Deallocate Memory 154 ## Deallocate Memory
155 155
156 ```C 156 ```C

mercurial