jsonification into the core and ESL

This commit is contained in:
Anthony Minessale committed 2010-06-17 11:43:09 -05:00
1 parent 3026e639fe
commit c5086b1517
11 files changed
+1166 -69

No files matched your search

@@ -627,7 +627,7 @@ static JSBool event_serialize(JSContext * cx, JSObject * obj, uintN argc, jsval
{
struct event_obj *eo = JS_GetPrivate(cx, obj);
char *buf;
uint8_t isxml = 0;
uint8_t isxml = 0, isjson = 0;
if (!eo) {
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
@@ -638,6 +638,8 @@ static JSBool event_serialize(JSContext * cx, JSObject * obj, uintN argc, jsval
char *arg = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
if (!strcasecmp(arg, "xml")) {
isxml++;
} else if (!strcasecmp(arg, "json")) {
isjson++;
}
}
@@ -652,6 +654,11 @@ static JSBool event_serialize(JSContext * cx, JSObject * obj, uintN argc, jsval
} else {
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
}
} else if (isjson) {
if (switch_event_serialize_json(eo->event, &buf) == SWITCH_STATUS_SUCCESS) {
*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, buf));
switch_safe_free(buf);
}
} else {
if (switch_event_serialize(eo->event, &buf, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, buf));