And in fact, that if we DO NOT do anything in toJSON for NumberType, and just return it as-is, the JSON library will do a much better job in formatting it as "expected", incl both without quotes as well as proper rounding off for the IEEE-754 issue.
Unfortunately, this constitutes an incompatible change. I'll ask separately about how to handle this On Sun, May 9, 2010 at 1:29 PM, Niclas Hedhman <[email protected]> wrote: > Another issue I find is that the serialization is inconsistent. > > A float collection becomes; > > [1.2199999929323, 2.39998989347] > > whereas a BigDecimal becomes > ["1.22","2.40"] > > Note the quotes, not the decimals which are IEEE-754 related! > > This is because the BigDecimal is handled with a toString() whereas > the other numbers are done with toLong() or toDouble(). > > From a purists point of view, this is very inconsistent and I suggest > we fix this sooner rather than later. > > > On Sun, May 9, 2010 at 1:11 PM, Niclas Hedhman <[email protected]> wrote: >> On Sun, May 9, 2010 at 6:15 AM, Stanislav Muhametsin >> <[email protected]> wrote: >>> Currently the JSONEntityState throws JSONException if there is a null value >>> in some collection property. It seems that the problem is in >>> org.qi4j.runtime.types.CollectionType . Replacing line 108 from >>> >>> Object value = array.get( i ); >>> >>> to >>> >>> Object value = array.opt( i ); >>> >>> fixed the problem. >> >> Well, I am also looking at the toJSON, and wondering does it really >> work to write it out in the first place? >> >> I am looking at CollectionType, it calls for instance toJSON in >> NumberType, which does a method call the passed value, i.e. the null. >> >> What am I missing? I'll try to put together a couple of tests to capture >> this. >> >> >> Cheers >> -- >> Niclas Hedhman, Software Developer >> http://www.qi4j.org - New Energy for Java >> >> I live here; http://tinyurl.com/2qq9er >> I work here; http://tinyurl.com/2ymelc >> I relax here; http://tinyurl.com/2cgsug >> > > > > -- > Niclas Hedhman, Software Developer > http://www.qi4j.org - New Energy for Java > > I live here; http://tinyurl.com/2qq9er > I work here; http://tinyurl.com/2ymelc > I relax here; http://tinyurl.com/2cgsug > -- Niclas Hedhman, Software Developer http://www.qi4j.org - New Energy for Java I live here; http://tinyurl.com/2qq9er I work here; http://tinyurl.com/2ymelc I relax here; http://tinyurl.com/2cgsug _______________________________________________ qi4j-dev mailing list [email protected] http://lists.ops4j.org/mailman/listinfo/qi4j-dev

