Hi Yasuo,

On Wed, Jun 10, 2015 at 11:57 AM, Yasuo Ohgaki <yohg...@ohgaki.net> wrote:

> Hi Derick,
>
> On Wed, Jun 10, 2015 at 7:28 PM, Derick Rethans <der...@php.net> wrote:
>
>> > Hi,
>> >
>> > The voting is now open:
>> >
>> > https://wiki.php.net/rfc/json_numeric_as_string#voting
>>
>> FWIW, I voted no to all of them because (as you even say in the RFC),
>> this is probably better be solved with a JSON schema thingy.
>
>
> JSON Schema does not help to decoding/encoding numeric data without
> loosing data.
>
> JSON Schema Core
> http://json-schema.org/latest/json-schema-core.html#anchor8
> Note: JSON specification does not specify precision. So number could be
> any number.
>
> JSON Schema Validation
> http://json-schema.org/latest/json-schema-validation.html#anchor5
>
> Those who do not care rounding errors/etc, they can use default behavior.
>
>
The idea would be to use JSON schema just for selecting the type for
deserialized item in decoded JSON. It means that you could for example
select one float item that you want to decode as a string but other floats
would be still decoded as floats. That gives a better flexibility and helps
the problem in the same way. Please see my email to Alexey when we
discussed this RFC (there are few examples):

https://www.mail-archive.com/internals@lists.php.net/msg78698.html

Cheers

Jakub

Reply via email to