Phalanger json_decode problem

Discussion about the open-source Phalanger [?] project.

Phalanger json_decode problem

Postby AdeHall » October 11th, 2012, 12:48 pm

I have a php json string as follows:

Code: Select all
$response="{\"calls\":[{\"data\":{\"1608630144506594e510521\":{\"message\":\"Hi friend! Please take these servings of Onion Broth with my compliments. I\u2019m sure they\u2019ll go down well on your Ranch!\",\"type\":\"gift\",\"from\":321016942048,\"timestamp\":1348834533,\"title\":\"Kingdom Quest\",\"fbRequestId\":\"416247058424493\",\"sendKey\":\"f337911ac5c8e2e03febac1j4!a5gqYruUpFMGT02jkI0SXRK!634xj971Kkswxx)NUTKkswxxj971Kkswxxj971\",\"data\":{\"action\":\"sendgift\",\"uidFrom\":100003801210309}},\"1284821833506daa2b49b8d\":{\"message\":\"Hey friend! Please help me in Kingdom Quest!\",\"type\":\"help\",\"from\":\"200637653111\",\"timestamp\":1349364267,\"title\":\"Kingdom Quest\",\"fbRequestId\":\"367570213319824\",\"sendKey\":\"de7ed9c56aa99e47b6a1ed0c1783705a$$dcF2Q.UX!*c4!a5g-cqYsq,lFMGT02kfL0P,VK!634xj971Kkswxx)NUTKkswxxj971Kkswxxj971\",\"data\":{\"action\":\"staffing\",\"userIdList\":\"5899859037\",\"userIdFrom\":\"62466565\",\"relatedEntityId\":1000653627,\"relatedTemplateId\":\"common_dragon_nest\"}},\"1967526190507550247a91a\":{\"message\":\"Hey friend! How'd you like to make a fortune with me in Kingdom Quest? Grow crops and animals, harvest ingredients and use them to cook dishes!\",\"type\":\"invite\",\"from\":321016492048,\"timestamp\":1349865508,\"title\":\"Kingdom Quest\",\"fbRequestId\":\"189633911171920\",\"sendKey\":\"996df61944a871e4589e128a6be3558a$$eeG(O,SU)2j4!a5g-cqYtz2e80GKX*egO4TZTS5YckxWF9a5iYyG,hFVOS2YyG,hF9a5iYyG,hF9a5i\",\"data\":{\"action\":\"invite\",\"src\":\"invite\",\"uid\":100000801210309}}}}],\"token\":\"NDAwMTMzYWQ1YTdlMDY0OTlhYjczZTE3MTdmMjUwNWNiY2ZlNjM1ZTRlOTRmMzhmZGRkMzc1ODA0MzJmMWM5Znx1fDIwMDTg3fDEwMDAwMDE5MnwxMzQ5OTY2MDU0fDF8QUFBRFpDejVwTFM2QUJBR2tubGhON1I2NjlIakJ3Y2tjUEs0UjJRcDFrRFFTTVdaQWZONWhYeXJ2Q3JXZzVDOXp3b1B0UTdKSU9aQTFkNU1KclMwakIwZnA4R01RNEo3cE14N2l4T3Fnd1pEWkQ\",\"zid\":\"2000645601187\"}"


We then json decode it

$response = json_decode($response, true);

but the resulting array has truncated the key from "1608630144506594e510521"

to "1608630144"

i.e.

- "data" {array(3)} string => array
- 1608630144 {array(8)} integer => array


Any ideas why this would happen? The rest of the decode seems to work ok

Thanks
Ade
AdeHall
 
Posts: 1
Joined: October 11th, 2012, 11:28 am

Re: Phalanger json_decode problem

Postby Jakub Misek » October 11th, 2012, 4:38 pm

Thanks for reporting this behaviour. Phalanger is trying to convert key to number ... but as you see, this conversion is not correct. This will be fixed.

This affects also simple array access operations.

Code: Select all
var_dump( array("1608630144506594e510521" => 0) );
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague


Return to Phalanger project

Who is online

Users browsing this forum: No registered users and 22 guests

cron

User Control Panel

Login

Who is online

In total there are 22 users online :: 0 registered, 0 hidden and 22 guests (based on users active over the past 5 minutes)
Most users ever online was 256 on March 28th, 2024, 9:42 am

Users browsing this forum: No registered users and 22 guests