mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
535 B
26 lines
535 B
=proto
|
|
void duk_json_decode(duk_context *ctx, int index);
|
|
|
|
=stack
|
|
[ ... json_val! ... ] -> [ ... val! ... ]
|
|
|
|
=summary
|
|
<p>Decodes an arbitrary JSON value as an in-place operation.
|
|
If the input is invalid, throws an error.</p>
|
|
|
|
=example
|
|
duk_push_string(ctx, "{\"meaningOfLife\":42}");
|
|
duk_json_decode(ctx, -1);
|
|
duk_get_prop_string(ctx, -1, "meaningOfLife");
|
|
printf("JSON decoded meaningOfLife is: %s\n", duk_to_string(ctx, -1));
|
|
duk_pop_2(ctx);
|
|
|
|
/* Output:
|
|
* JSON decoded meaningOfLife is: 42
|
|
*/
|
|
|
|
=tags
|
|
codec
|
|
|
|
=seealso
|
|
duk_json_encode
|
|
|