[jboss-as7-dev] json vs custom parser

Jason T. Greene jason.greene at redhat.com
Wed Feb 2 13:09:57 EST 2011


On 2/2/11 11:05 AM, Heiko Braun wrote:
>
> Thats not what I meant. I am not asking for a parsing the binary protocol
> in Javascript. I was simply wondering if the DMR model could be
> decoupled form the dependencies
> the GWT compiler doesn't support. Simply to reuse it, in order to
> express operations, etc on the client.
> No big deal if that doesn't work.

Well I suppose you could port it in a similar manner but only use the 
JSON serialization mechanism. You would still need a custom unmarshaller 
under this scenario though because the DMR java impl has to actually 
parse and convert the output. The unmarshaller would be simpler though 
since you can either reuse the JSON object model that has been evaled or 
somehow map it.

> But back to your proposal:
> I don't believe parsing the binary protocol will be more efficient then
> natively evaluating the JSON
> bit's and pieces. Which typically is what you do in GWT.

It is certainly possible that the gain would be minimal since javascript 
is already optimized at self-parsing, and it is not very good at munging 
binary data.

Although, I think the advantage of doing the binary approach though is 
more in having more accurate type representation. JSON does map somewhat 
close, but it lacks certain types that we have to provide hints for. As 
an example there is no such thing as a byte sequence, so we use base64. 
However, then you have to know the difference between base64 and a 
string. So to solve issues like this we use JSON objects that have 
fields indicating how they should be interpreted.


> But before we dive too much into assumptions, let's stick to the
> requirements:
> JSON works fine. So far there is no need for the binary protocol in GWT.
> We would need to identify a performance problem first,
>

I agree that it is not a priority atm. If the JSON approach becomes 
cumbersome, and we have the bandwidth, we could change that. Ultimately, 
IMO, we still need JSON support for ease-of-use from users.

-- 
Jason T. Greene
JBoss, a division of Red Hat



More information about the jboss-as7-dev mailing list