Improve the JSON C API (#3943)
* Added more details into documentation. * Moved the C unit-test into its own file. * Added extra test cases. * Extended the API reference documentation with doctests. JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
This commit is contained in:
@@ -214,7 +214,7 @@ typedef struct
|
||||
|
||||
ecma_value_t ecma_builtin_json_parse_buffer (const lit_utf8_byte_t * str_start_p,
|
||||
lit_utf8_size_t string_size);
|
||||
ecma_value_t ecma_builtin_json_string_from_object (const ecma_value_t arg1);
|
||||
ecma_value_t ecma_builtin_json_stringify_no_opts (const ecma_value_t value);
|
||||
bool ecma_json_has_object_in_stack (ecma_json_occurence_stack_item_t *stack_p, ecma_object_t *object_p);
|
||||
bool ecma_has_string_value_in_collection (ecma_collection_t *collection_p, ecma_string_t *string_p);
|
||||
|
||||
|
||||
@@ -1349,13 +1349,16 @@ static ecma_value_t ecma_builtin_json_str_helper (ecma_json_stringify_context_t
|
||||
} /* ecma_builtin_json_str_helper */
|
||||
|
||||
/**
|
||||
* Function to create a json formated string from an object
|
||||
* Function to create a JSON string from a JS value.
|
||||
*
|
||||
* @return ecma_value_t containing a json string
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
* Note:
|
||||
* The returned value must be freed with ecma_free_value.
|
||||
*
|
||||
* @return - ecma_value_t containing a json string.
|
||||
* - Error value in case of any errors.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_json_string_from_object (const ecma_value_t arg1) /**< object argument */
|
||||
ecma_builtin_json_stringify_no_opts (const ecma_value_t value) /**< value to stringify */
|
||||
{
|
||||
ecma_json_stringify_context_t context;
|
||||
context.occurence_stack_last_p = NULL;
|
||||
@@ -1364,12 +1367,12 @@ ecma_builtin_json_string_from_object (const ecma_value_t arg1) /**< object argum
|
||||
context.replacer_function_p = NULL;
|
||||
context.gap_str_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
|
||||
|
||||
ecma_value_t ret_value = ecma_builtin_json_str_helper (&context, arg1);
|
||||
ecma_value_t ret_value = ecma_builtin_json_str_helper (&context, value);
|
||||
|
||||
ecma_deref_ecma_string (context.gap_str_p);
|
||||
ecma_stringbuilder_destroy (&context.indent_builder);
|
||||
return ret_value;
|
||||
} /*ecma_builtin_json_string_from_object*/
|
||||
} /* ecma_builtin_json_stringify_no_opts */
|
||||
|
||||
/**
|
||||
* The JSON object's 'stringify' routine
|
||||
|
||||
Reference in New Issue
Block a user