| 555 * @retval non-zero internal allocation error |
555 * @retval non-zero internal allocation error |
| 556 * @see cxJsonFilln() |
556 * @see cxJsonFilln() |
| 557 */ |
557 */ |
| 558 #define cxJsonFill(json, str) cx_json_fill(json, cx_strcast(str)) |
558 #define cxJsonFill(json, str) cx_json_fill(json, cx_strcast(str)) |
| 559 |
559 |
| |
560 |
| |
561 /** |
| |
562 * Internal function - use cxJsonFromString() instead. |
| |
563 * |
| |
564 * @param allocator the allocator for the JSON value |
| |
565 * @param str the string to parse |
| |
566 * @param value a pointer where the JSON value shall be stored to |
| |
567 * @return status code |
| |
568 */ |
| |
569 cx_attr_nonnull_arg(3) |
| |
570 CX_EXPORT CxJsonStatus cx_json_from_string(const CxAllocator *allocator, |
| |
571 cxstring str, CxJsonValue **value); |
| |
572 |
| |
573 /** |
| |
574 * Parses a string into a JSON value. |
| |
575 * |
| |
576 * @param allocator (@c CxAllocator*) the allocator for the JSON value |
| |
577 * @param str (any string) the string to parse |
| |
578 * @param value (@c CxJsonValue**) a pointer where the JSON value shall be stored to |
| |
579 * @retval CX_JSON_NO_ERROR success |
| |
580 * @retval CX_JSON_NO_DATA the string was empty or blank |
| |
581 * @retval CX_JSON_INCOMPLETE_DATA the string unexpectedly ended |
| |
582 * @retval CX_JSON_BUFFER_ALLOC_FAILED allocating internal buffer space failed |
| |
583 * @retval CX_JSON_VALUE_ALLOC_FAILED allocating memory for the CxJsonValue failed |
| |
584 * @retval CX_JSON_FORMAT_ERROR_NUMBER the JSON text contains an illegally formatted number |
| |
585 * @retval CX_JSON_FORMAT_ERROR_UNEXPECTED_TOKEN JSON syntax error |
| |
586 */ |
| |
587 #define cxJsonFromString(allocator, str, value) \ |
| |
588 cx_json_from_string(allocator, cx_strcast(str), value) |
| |
589 |
| 560 /** |
590 /** |
| 561 * Creates a new (empty) JSON object. |
591 * Creates a new (empty) JSON object. |
| 562 * |
592 * |
| 563 * @param allocator the allocator to use |
593 * @param allocator the allocator to use |
| 564 * @return the new JSON object or @c NULL if allocation fails |
594 * @return the new JSON object or @c NULL if allocation fails |