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
537 B

=proto
const char *duk_json_encode(duk_context *ctx, int index);
=stack
[ ... val! ... ] -> [ ... json_val! ... ]
=summary
<p>Encodes an arbitrary value into its JSON representation as an in-place
operation. Returns pointer to the resulting string for convenience.</p>
=example
duk_push_object(ctx);
duk_push_int(ctx, 42);
duk_put_prop_string(ctx, -2, "meaningOfLife");
printf("JSON encoded: %s\n", duk_json_encode(ctx, -1));
duk_pop(ctx);
/* Output:
* JSON encoded: {"meaningOfLife":42}
*/
=tags
codec
=seealso
duk_json_decode