P
Pavils Jurjans
Hello,
I have a fairly complex project with server-side written in C# (.NET),
and client-side heavily relying on the presence on
JavaScript-compatible scripting engine. One of the features thie
project utilizes is "virtual POST", ie, client side submits the data
to the server side, using Microsoft.XMLHTTP ActiveX Object (in MSIE),
or XMLHttpRequest class in Mozilla, and when the server returns reply,
processes it in client side to run some JavaScript and manipulate with
DOM.
The thing is, I am looking for decent, not-too-verbose data
serialization encoding that would allow me to send JavaScript-type
data to the server and back. With JavaScript-type data I mean value
that could be described as one of the following:
0) null
1) numeric value
2) string value in quotes
3) boolean value: true/false
4) date value: new Date(x, y, z)
5) array: [value, value, ...]
6) object: {value:value, value:value, ...}
Here is example of the tata that I want to be able to xfer to and from
the server:
[1, "abc", true, {a:1, b:[10,11,12, new Date(x, y, z)], c:{x:"foo",
y:"bar"}}]
Until today , I used JSON (http://www.crockford.com/JSON/index.html)
notation, cause I find it short and to the point. I have wrote my own
JavaScript code for encoding and decoding the data to and from the
JSON. However, I have stumbled upon the situation that for large data
blocks the client-side scripting engine is too weak to parse it in
reasonable time, and I am forced to use another encoding. So, now I am
thinking on XML encoding. The example above could be encoded like
this:
<value type="array">
<value type="num" value="1"/>
<value type="str" value="abc"/>
<value type="bool" vaue="true"/>
<value type="object">
<value key="a" type="num" value="1"/>
<value key="b" type="array">
<value type="num" value="10"/>
<value type="num" value="11"/>
<value type="num" value="12"/>
<value type="date" value="x y z"/>
</value>
<value key="c" type="object">
<value key="x" type="str" value="foo"/>
<value key="y" type="str" value="bar"/>
</value>
</value>
</value>
Which, of course, is much more verbose, but still the shortest way I
can think of to describe the JavaScript data structures in XML. Plus,
I could do speedy parsing on the client-side using built-in XML
parsers (vs present JSON parse that is driven by series of Regex
searches that make it slow).
So, my question is, whether there is already some running initiative
on this matter, and perhaps I need not to reinvent the wheel, and
JavaScript encoding/decoding code for this serialization format is
available?
Regards,
Pavils Jurjans
I have a fairly complex project with server-side written in C# (.NET),
and client-side heavily relying on the presence on
JavaScript-compatible scripting engine. One of the features thie
project utilizes is "virtual POST", ie, client side submits the data
to the server side, using Microsoft.XMLHTTP ActiveX Object (in MSIE),
or XMLHttpRequest class in Mozilla, and when the server returns reply,
processes it in client side to run some JavaScript and manipulate with
DOM.
The thing is, I am looking for decent, not-too-verbose data
serialization encoding that would allow me to send JavaScript-type
data to the server and back. With JavaScript-type data I mean value
that could be described as one of the following:
0) null
1) numeric value
2) string value in quotes
3) boolean value: true/false
4) date value: new Date(x, y, z)
5) array: [value, value, ...]
6) object: {value:value, value:value, ...}
Here is example of the tata that I want to be able to xfer to and from
the server:
[1, "abc", true, {a:1, b:[10,11,12, new Date(x, y, z)], c:{x:"foo",
y:"bar"}}]
Until today , I used JSON (http://www.crockford.com/JSON/index.html)
notation, cause I find it short and to the point. I have wrote my own
JavaScript code for encoding and decoding the data to and from the
JSON. However, I have stumbled upon the situation that for large data
blocks the client-side scripting engine is too weak to parse it in
reasonable time, and I am forced to use another encoding. So, now I am
thinking on XML encoding. The example above could be encoded like
this:
<value type="array">
<value type="num" value="1"/>
<value type="str" value="abc"/>
<value type="bool" vaue="true"/>
<value type="object">
<value key="a" type="num" value="1"/>
<value key="b" type="array">
<value type="num" value="10"/>
<value type="num" value="11"/>
<value type="num" value="12"/>
<value type="date" value="x y z"/>
</value>
<value key="c" type="object">
<value key="x" type="str" value="foo"/>
<value key="y" type="str" value="bar"/>
</value>
</value>
</value>
Which, of course, is much more verbose, but still the shortest way I
can think of to describe the JavaScript data structures in XML. Plus,
I could do speedy parsing on the client-side using built-in XML
parsers (vs present JSON parse that is driven by series of Regex
searches that make it slow).
So, my question is, whether there is already some running initiative
on this matter, and perhaps I need not to reinvent the wheel, and
JavaScript encoding/decoding code for this serialization format is
available?
Regards,
Pavils Jurjans