[erlang-questions] Best way to send JSON from erlang to the browser and back

Andrew Berman <>
Fri Nov 25 19:48:39 CET 2011


Joe,

I know you had another email related to this, but I'm wondering why you
couldn't use BERT and on the Erlang side, base64 encode it (so Jquery AJAX
can work with it), then base64 decode it in the JavaScript and use BERT-JS (
https://github.com/rustyio/BERT-JS) and the same thing going the other way.
 This should ensure that things never change between
serialization/deserialization.

Just a thought....

Andrew

On Fri, Nov 25, 2011 at 10:19 AM, Joe Armstrong <> wrote:

>
>
> On Fri, Nov 25, 2011 at 6:10 PM, Max Lapshin <>wrote:
>
>> Joe, so do you have any problems with it?
>>
>
> Yes - if you as I pointed out the encode and decode in
> mochijson2 are not inverses so
>
>     X = decode(encode(X)) is not always true
>
> bignums can get clobbered - floats might change precision
>
> the behaviour or duplicated tags is undefined.
>
> If I say X = {a:1, b:2, a:2} then encode and decode it  then ask what is
> X.a is it 1 or 2 ? who knows
>
>
>>
>> If no, than don't be afraid. JSON is a really simple thing.
>>
>
> It looks simple - anyway it would be much better to send
> binary encodings which need no parsing, rather that things that
> need to be parsed.
>
> /Joe
>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111125/4241d875/attachment.html>


More information about the erlang-questions mailing list