summaryrefslogtreecommitdiff
path: root/jsonrpc/json.esp
diff options
context:
space:
mode:
Diffstat (limited to 'jsonrpc/json.esp')
-rw-r--r--jsonrpc/json.esp28
1 files changed, 22 insertions, 6 deletions
diff --git a/jsonrpc/json.esp b/jsonrpc/json.esp
index ad0e13a6c3..32f0fa776a 100644
--- a/jsonrpc/json.esp
+++ b/jsonrpc/json.esp
@@ -37,6 +37,11 @@ function _escape(s)
}
}
+ if (arr.length == 0)
+ {
+ return "";
+ }
+
return join("", arr);
}
@@ -72,10 +77,14 @@ function _encode(o)
}
else if (type == "float" ||
type == "integer" ||
- type == "integer64" ||
- type == "pointer")
+ type == "integer64")
+ {
+ return o + 0;
+ }
+ else if (type == "pointer")
{
- return (o + 0);
+ var x = "" + o;
+ return '"' + substr(x, 16, strlen(x) - 16 - 1) + '"';
}
else if (type == "object")
{
@@ -128,6 +137,10 @@ function _encode(o)
{
return '"' + this._internal.escape(o) + '"';
}
+ else
+ {
+ return '{ "unknown_object":"' + type + '"}';
+ }
}
/* Allocate the public Json access object */
@@ -193,6 +206,7 @@ Json._internal.convert['\x1f'] = '\\u001f';
/* Test it */
+/*
libinclude("base.js");
function testFormat()
{
@@ -211,7 +225,11 @@ function testFormat()
test.obj.array[1] = 223;
printf("%s\n", Json.encode(test));
}
+testFormat();
+*/
+/*
+libinclude("base.js");
function testParse()
{
var s;
@@ -236,8 +254,6 @@ function testParse()
obj = Json.decode(s);
printf("Decode/encode of\n\t%s\nyielded\n\t%s\n\n", s, Json.encode(obj));
}
-
-//testFormat();
testParse();
-
+*/
%>