librelist archives

« back to archive

yajl 32-bit vs 64-bit

yajl 32-bit vs 64-bit

From:
Vikas N Kumar
Date:
2010-10-04 @ 21:35
Hi

I am a user of YAJL and am looking for a capability for 32-bit
operating systems like Windows to handle 64-bit numbers/integers in the JSON
format.

Currently "long int" is being used for integers, which on 32-bit systems is
4 bytes, and on 64-bit systems is 8 bytes. So when using JSON as a data
serialization format between a 32-bit app and a 64-bit app, the 64-bit
integers sent from the 64-bit app to the 32-bit app get either dropped or
wrongly parsed.

Is there a way for fixing this ?

Thanks
Vikas

Re: [yajl] yajl 32-bit vs 64-bit

From:
Lloyd Hilaiel
Date:
2010-10-04 @ 21:45
Yo Vikas,

you can use the yajl_number callback rather than yajl_double or yajl_integer.

This will pass you back the raw string lexed out of JSON text and will allow
you to convert it into a binary representation by yourself (like, say, a 
long long).

It's worth noting that on the 2.x branch we've moved to 'long long' to represent
integers.  That move was made after c99 was required, but won't be merged to
yajl 1 for api compat reasons:
http://github.com/lloyd/yajl/blob/2.x/src/api/yajl_parse.h

best!
lloyd

On Mon, Oct 04, 2010 at 05:35:42PM -0400, Vikas N Kumar wrote:
> Hi
> 
> I am a user of YAJL and am looking for a capability for 32-bit
> operating systems like Windows to handle 64-bit numbers/integers in the JSON
> format.
> 
> Currently "long int" is being used for integers, which on 32-bit systems is
> 4 bytes, and on 64-bit systems is 8 bytes. So when using JSON as a data
> serialization format between a 32-bit app and a 64-bit app, the 64-bit
> integers sent from the 64-bit app to the 32-bit app get either dropped or
> wrongly parsed.
> 
> Is there a way for fixing this ?
> 
> Thanks
> Vikas

Re: [yajl] yajl 32-bit vs 64-bit

From:
Vikas N Kumar
Date:
2010-10-05 @ 17:16
On Mon, Oct 4, 2010 at 5:45 PM, Lloyd Hilaiel <lloyd@hilaiel.com> wrote:

>
> you can use the yajl_number callback rather than yajl_double or
> yajl_integer.
>
> This will pass you back the raw string lexed out of JSON text and will
> allow
> you to convert it into a binary representation by yourself (like, say, a
> long long).
>
>
Thanks. This might work as then I can force the conversion to a double or a
long. Is there scope for handling a Nan ?

--Vikas