Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #2787 > unrolled thread
| Started by | Falk Fiedler <falk.fiedler@googlemail.com> |
|---|---|
| First post | 2011-08-11 02:23 -0700 |
| Last post | 2011-08-11 15:00 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.php
json_decode Falk Fiedler <falk.fiedler@googlemail.com> - 2011-08-11 02:23 -0700
Re: json_decode Jerry Stuckle <jstucklex@attglobal.net> - 2011-08-11 06:48 -0400
Re: json_decode "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-08-11 15:00 +0200
| From | Falk Fiedler <falk.fiedler@googlemail.com> |
|---|---|
| Date | 2011-08-11 02:23 -0700 |
| Subject | json_decode |
| Message-ID | <5c4491dc-f228-43e2-a2cd-98cfa6f81d0a@w11g2000vbp.googlegroups.com> |
hi, i get from a API a JSON-String with the field: "id":1070107173001 with json_decode i get: id = 1.070107173E+12 and i can't work with this value ... is this right, what can i do? thank you falk
[toc] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2011-08-11 06:48 -0400 |
| Message-ID | <j20c13$a29$2@dont-email.me> |
| In reply to | #2787 |
On 8/11/2011 5:23 AM, Falk Fiedler wrote: > hi, > > i get from a API a JSON-String with the field: > > "id":1070107173001 > > with json_decode i get: > > id = 1.070107173E+12 > > and i can't work with this value ... is this right, what can i do? > > thank you > > > falk Yes, it is correct. The value is larger than a 32 bit integer can hold, so PHP creates a float type out of it. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> |
|---|---|
| Date | 2011-08-11 15:00 +0200 |
| Message-ID | <j20jp6$s8v$1@dont-email.me> |
| In reply to | #2787 |
El 11/08/2011 11:23, Falk Fiedler escribió/wrote: > i get from a API a JSON-String with the field: > > "id":1070107173001 > > with json_decode i get: > > id = 1.070107173E+12 > > and i can't work with this value ... is this right, what can i do? > > thank you In my computer, it creates a float but it doesn't lose precision. You should be able to work with it without any problem. If you are getting scientific notation it's because you are casting it to string with a function that does not let you choose the format. Just handle it as number. -- -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain -- Mi sitio sobre programación web: http://borrame.com -- Mi web de humor satinado: http://www.demogracia.com --
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web