Re: JSON float number as string
| From: | Jakub Zelenka | Date: | Fri, 10 Apr 2015 16:37:27 +0000 |
| Subject: | Re: JSON float number as string | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-85771@lists.php.net to get a copy of this message | ||
Hi Yasuo,
On Fri, Apr 10, 2015 at 1:29 AM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote:
>
> Could you add "json_encode" type hint also?
>
> Large int/float must be treated as string or GMP object (we don't have GMP
> float yet, though)
>
Currently, there is no way to encode large "numeric" JSON data correctly
> when it is stored as
> string.
>
> string json_encode ( mixed $value [, int $options = 0 [, int $depth = 512
> [, array $type_spec = NULL]]] )
>
> where $type_spec specifies correct data representation. i.e. numeric,
> string, bool
>
> json_encode() type hint should work like Zeev's type hint.
> i.e. No data type conversion, but validate its content.
>
>
Again this is a bit off-topic. I think that it would be good if you could
create a bug report for this. It would be great to add an example how the
$type_spec should work (e.g. if you mean something like
http://json-schema.org/examples.html )
Cheers
Jakub