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
573 B
26 lines
573 B
11 years ago
|
/*===
|
||
|
duk_is_object(1) = 1
|
||
|
json encoded: {"meaningOfLife":42}
|
||
|
top=2
|
||
|
===*/
|
||
|
|
||
|
void test(duk_context *ctx) {
|
||
11 years ago
|
duk_idx_t obj_idx;
|
||
11 years ago
|
|
||
|
duk_push_int(ctx, 123); /* dummy */
|
||
|
|
||
11 years ago
|
obj_idx = duk_push_object(ctx);
|
||
11 years ago
|
duk_push_int(ctx, 42);
|
||
|
duk_put_prop_string(ctx, obj_idx, "meaningOfLife");
|
||
|
|
||
|
/* object is now: { "meaningOfLife": 42 } */
|
||
|
|
||
11 years ago
|
printf("duk_is_object(%ld) = %d\n", (long) obj_idx, (int) duk_is_object(ctx, obj_idx));
|
||
11 years ago
|
|
||
|
duk_json_encode(ctx, obj_idx); /* in-place */
|
||
|
|
||
|
printf("json encoded: %s\n", duk_get_string(ctx, obj_idx));
|
||
|
|
||
11 years ago
|
printf("top=%ld\n", (long) duk_get_top(ctx));
|
||
11 years ago
|
}
|