summaryrefslogtreecommitdiff
path: root/src/js.c
diff options
context:
space:
mode:
authorportix <none@none>2012-04-29 13:09:56 +0200
committerportix <none@none>2012-04-29 13:09:56 +0200
commit3b75a96b57033f35f2e2aa983319760f9ce01f79 (patch)
tree21c0c7791fceaadf96dbea4144e31b11e3e31fe0 /src/js.c
parent1ee05fad020a5af499d0283273af4cb4f9c13d2b (diff)
downloaddwb-3b75a96b57033f35f2e2aa983319760f9ce01f79.zip
Get gobject properties from scripts; started rewriting of documentation
--HG-- branch : scripts
Diffstat (limited to 'src/js.c')
-rw-r--r--src/js.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/js.c b/src/js.c
index 2985b432..e08a7cf8 100644
--- a/src/js.c
+++ b/src/js.c
@@ -201,3 +201,16 @@ js_value_to_char(JSContextRef ctx, JSValueRef value, size_t limit, JSValueRef *e
JSStringRelease(jsstring);
return ret;
}/*}}}*/
+
+char *
+js_value_to_json(JSContextRef ctx, JSValueRef value, size_t limit, JSValueRef *exc) {
+ if (value == NULL)
+ return NULL;
+ JSStringRef js_json = JSValueCreateJSONString(ctx, value, 2, exc);
+ if (js_json == NULL)
+ return NULL;
+ char *json = js_string_to_char(ctx, js_json, limit);
+ JSStringRelease(js_json);
+ return json;
+}
+