=proto const char *duk_json_encode(duk_context *ctx, int index); =stack [ ... val! ... ] -> [ ... json_val! ... ] =summary

Encodes an arbitrary value into its JSON representation as an in-place operation. Returns pointer to the resulting string for convenience.

=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