Thanks for the quick response.  I have a workaround in place now.  The 
issue is that the serialization/deserialization of the object to Map may 
get either a long or a double depending where the data came from, while 
it's always written as double type.  I'm not exactly sure how other numbers 
will behave, integers seem to stay as integers etc.

The approach is to promote all primitive number types to double then cast 
back to their respective type.

On Thursday, August 14, 2014 12:32:04 PM UTC-4, Jens Alfke wrote:
>
>
> On Aug 14, 2014, at 6:38 AM, James Norman <[email protected] 
> <javascript:>> wrote:
>
> I'm storing a long in the properties map of a local database and syncing 
> that with others.  In the local database it is returned as a Long which is 
> correct, but when synced to other databases it is returned as a Double. 
>
>
> That's expected behavior. The JSON format doesn't distinguish between 
> integer and floating-point; it just has a single "number" type. It's up to 
> the parser code how that's converted to a platform data type.  Sounds like 
> the JSON parser used by Java parses all JSON numbers to Doubles. If you 
> want the number in some other form, you'll need to cast it.
>
> (In case you're worried about round-off error: double-precision floating 
> point can exactly represent all integers up to about ±2^50.)
>
> —Jens
>

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/689035d0-74cf-42d4-a7f9-7c1de27f5cc3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to