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.
 
 
 
 
 
 

31 lines
632 B

name: duk_json_encode
proto: |
const char *duk_json_encode(duk_context *ctx, duk_idx_t idx);
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
- json
seealso:
- duk_json_decode
introduced: 1.0.0