-
Notifications
You must be signed in to change notification settings - Fork 686
Closed
Labels
feature requestRequested featureRequested feature
Description
I think it would be nice if the jerry-core.h API would have C APIs that match JSON.parse/stringify.
Proposal API:
typedef jerry_value_t (*jerry_json_reviver_t) (jerry_value_t key, jerry_value_t value);
jerry_value_t
jerry_json_parse_utf8 (const jerry_char_t *utf8_str,
size_t str_sz,
jerry_json_reviver_t reviver);
typedef jerry_value_t (*jerry_json_replacer_t) (jerry_value_t key, jerry_value_t value);
jerry_value_t
jerry_json_stringify(jerry_value_t value,
jerry_json_replacer_t replacer,
jerry_value_t space);
Note the output of jerry_json_stringify is not a UTF-8 C string (jerry_char_t[]). Although in most cases you probably want a C string...:
- how to allocate the buffer for the C string?
- what's an elegant way to deal with any errors – perhaps a
jerry_value_t *error_out?
Thoughts?
Metadata
Metadata
Assignees
Labels
feature requestRequested featureRequested feature