Bug #63007 [Com]: json functions corrupt arrayindizes

2012-09-04 Thread reeze dot xia at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=63007edit=1

 ID: 63007
 Comment by: reeze dot xia at gmail dot com
 Reported by:janfili+phpbugs at gmail dot com
 Summary:json functions corrupt arrayindizes
 Status: Open
 Type:   Bug
 Package:JSON related
 Operating System:   Linux ubuntu1010
 PHP Version:5.3.16
 Block user comment: N
 Private report: N

 New Comment:

This is not a problem of JSON itself.

but. array vs object conversion. and it was documented:
http://www.php.net/manual/en/language.types.array.php#language.types.array.casti
ng

after json_encode  key: 1 was encoded as string.
In object properties and only been string key.

but after convert to array, it will not be able to accessed since.
if the key will be changed to number key if possible.


similar to https://bugs.php.net/bug.php?id=54082


Previous Comments:

[2012-09-04 07:38:41] janfili+phpbugs at gmail dot com

Description:

after json en/decoding the original array index cant be used to retrieve the 
values.

however foreach and all other array-related functions work as expected.

Test script:
---
?

$class = new stdClass();
$class-field = 'foo';
var_dump($class);
$array = array(1 = $class);
var_dump($array);
$json_sting = json_encode($array);
var_dump($json_sting);
$array_obj = json_decode($json_sting);
var_dump($array_obj);
$array = (array) $array_obj;
var_dump($array);
var_dump($array[1]);

?

Expected result:

output of last var_dump is expected to be 

object(stdClass)#3 (1) {
[field]=
string(3) foo
  }

Actual result:
--
NULL






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63007edit=1


Bug #63007 [Com]: json functions corrupt arrayindizes

2012-09-04 Thread janfili+phpbugs at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=63007edit=1

 ID: 63007
 Comment by: janfili+phpbugs at gmail dot com
 Reported by:janfili+phpbugs at gmail dot com
 Summary:json functions corrupt arrayindizes
 Status: Open
 Type:   Bug
 Package:JSON related
 Operating System:   Linux ubuntu1010
 PHP Version:5.3.16
 Block user comment: N
 Private report: N

 New Comment:

using this var_dump($array['1']); as the last statement will not help either


Previous Comments:

[2012-09-04 08:04:22] reeze dot xia at gmail dot com

This is not a problem of JSON itself.

but. array vs object conversion. and it was documented:
http://www.php.net/manual/en/language.types.array.php#language.types.array.casti
ng

after json_encode  key: 1 was encoded as string.
In object properties and only been string key.

but after convert to array, it will not be able to accessed since.
if the key will be changed to number key if possible.


similar to https://bugs.php.net/bug.php?id=54082


[2012-09-04 07:38:41] janfili+phpbugs at gmail dot com

Description:

after json en/decoding the original array index cant be used to retrieve the 
values.

however foreach and all other array-related functions work as expected.

Test script:
---
?

$class = new stdClass();
$class-field = 'foo';
var_dump($class);
$array = array(1 = $class);
var_dump($array);
$json_sting = json_encode($array);
var_dump($json_sting);
$array_obj = json_decode($json_sting);
var_dump($array_obj);
$array = (array) $array_obj;
var_dump($array);
var_dump($array[1]);

?

Expected result:

output of last var_dump is expected to be 

object(stdClass)#3 (1) {
[field]=
string(3) foo
  }

Actual result:
--
NULL






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63007edit=1


Bug #63007 [Com]: json functions corrupt arrayindizes

2012-09-04 Thread reeze dot xia at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=63007edit=1

 ID: 63007
 Comment by: reeze dot xia at gmail dot com
 Reported by:janfili+phpbugs at gmail dot com
 Summary:json functions corrupt arrayindizes
 Status: Open
 Type:   Bug
 Package:JSON related
 Operating System:   Linux ubuntu1010
 PHP Version:5.3.16
 Block user comment: N
 Private report: N

 New Comment:

Ah, I'm sorry, the bug ID: #54082, I can't find the report right now.

will post that later


Previous Comments:

[2012-09-04 08:18:29] janfili+phpbugs at gmail dot com

using this var_dump($array['1']); as the last statement will not help either


[2012-09-04 08:04:22] reeze dot xia at gmail dot com

This is not a problem of JSON itself.

but. array vs object conversion. and it was documented:
http://www.php.net/manual/en/language.types.array.php#language.types.array.casti
ng

after json_encode  key: 1 was encoded as string.
In object properties and only been string key.

but after convert to array, it will not be able to accessed since.
if the key will be changed to number key if possible.


similar to https://bugs.php.net/bug.php?id=54082


[2012-09-04 07:38:41] janfili+phpbugs at gmail dot com

Description:

after json en/decoding the original array index cant be used to retrieve the 
values.

however foreach and all other array-related functions work as expected.

Test script:
---
?

$class = new stdClass();
$class-field = 'foo';
var_dump($class);
$array = array(1 = $class);
var_dump($array);
$json_sting = json_encode($array);
var_dump($json_sting);
$array_obj = json_decode($json_sting);
var_dump($array_obj);
$array = (array) $array_obj;
var_dump($array);
var_dump($array[1]);

?

Expected result:

output of last var_dump is expected to be 

object(stdClass)#3 (1) {
[field]=
string(3) foo
  }

Actual result:
--
NULL






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63007edit=1


Bug #63007 [Com]: json functions corrupt arrayindizes

2012-09-04 Thread reeze dot xia at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=63007edit=1

 ID: 63007
 Comment by: reeze dot xia at gmail dot com
 Reported by:janfili+phpbugs at gmail dot com
 Summary:json functions corrupt arrayindizes
 Status: Open
 Type:   Bug
 Package:JSON related
 Operating System:   Linux ubuntu1010
 PHP Version:5.3.16
 Block user comment: N
 Private report: N

 New Comment:

Yes, it will not accessible anymore if you have property with string number.
since array handle keys different from objects.


Previous Comments:

[2012-09-04 08:19:17] reeze dot xia at gmail dot com

Ah, I'm sorry, the bug ID: #54082, I can't find the report right now.

will post that later


[2012-09-04 08:18:29] janfili+phpbugs at gmail dot com

using this var_dump($array['1']); as the last statement will not help either


[2012-09-04 08:04:22] reeze dot xia at gmail dot com

This is not a problem of JSON itself.

but. array vs object conversion. and it was documented:
http://www.php.net/manual/en/language.types.array.php#language.types.array.casti
ng

after json_encode  key: 1 was encoded as string.
In object properties and only been string key.

but after convert to array, it will not be able to accessed since.
if the key will be changed to number key if possible.


similar to https://bugs.php.net/bug.php?id=54082


[2012-09-04 07:38:41] janfili+phpbugs at gmail dot com

Description:

after json en/decoding the original array index cant be used to retrieve the 
values.

however foreach and all other array-related functions work as expected.

Test script:
---
?

$class = new stdClass();
$class-field = 'foo';
var_dump($class);
$array = array(1 = $class);
var_dump($array);
$json_sting = json_encode($array);
var_dump($json_sting);
$array_obj = json_decode($json_sting);
var_dump($array_obj);
$array = (array) $array_obj;
var_dump($array);
var_dump($array[1]);

?

Expected result:

output of last var_dump is expected to be 

object(stdClass)#3 (1) {
[field]=
string(3) foo
  }

Actual result:
--
NULL






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63007edit=1


Bug #63007 [Com]: json functions corrupt arrayindizes

2012-09-04 Thread janfili+phpbugs at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=63007edit=1

 ID: 63007
 Comment by: janfili+phpbugs at gmail dot com
 Reported by:janfili+phpbugs at gmail dot com
 Summary:json functions corrupt arrayindizes
 Status: Not a bug
 Type:   Bug
 Package:JSON related
 Operating System:   Linux ubuntu1010
 PHP Version:5.3.16
 Block user comment: N
 Private report: N

 New Comment:

not similar to https://bugs.php.net/bug.php?id=51915

51915 mentions that the indexes become strings, and that is the case of course 
through json en/decoding.

The bug described in this ticket is that the elements belonging to these keys 
are not retrievable anymore. 

even if you explicitly get the keys

$k = array_keys($array);
echo $array[$k[0]];

will result in undefined index. Reductio ad absurdum


Previous Comments:

[2012-09-04 11:17:17] larue...@php.net

similar to https://bugs.php.net/bug.php?id=51915


[2012-09-04 08:21:08] reeze dot xia at gmail dot com

Yes, it will not accessible anymore if you have property with string number.
since array handle keys different from objects.


[2012-09-04 08:19:17] reeze dot xia at gmail dot com

Ah, I'm sorry, the bug ID: #54082, I can't find the report right now.

will post that later


[2012-09-04 08:18:29] janfili+phpbugs at gmail dot com

using this var_dump($array['1']); as the last statement will not help either


[2012-09-04 08:04:22] reeze dot xia at gmail dot com

This is not a problem of JSON itself.

but. array vs object conversion. and it was documented:
http://www.php.net/manual/en/language.types.array.php#language.types.array.casti
ng

after json_encode  key: 1 was encoded as string.
In object properties and only been string key.

but after convert to array, it will not be able to accessed since.
if the key will be changed to number key if possible.


similar to https://bugs.php.net/bug.php?id=54082




The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

https://bugs.php.net/bug.php?id=63007


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63007edit=1


Bug #63007 [Com]: json functions corrupt arrayindizes

2012-09-04 Thread janfili+phpbugs at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=63007edit=1

 ID: 63007
 Comment by: janfili+phpbugs at gmail dot com
 Reported by:janfili+phpbugs at gmail dot com
 Summary:json functions corrupt arrayindizes
 Status: Not a bug
 Type:   Bug
 Package:JSON related
 Operating System:   Linux ubuntu1010
 PHP Version:5.3.16
 Block user comment: N
 Private report: N

 New Comment:

Would you please read my comments carefully again?

as i mentioned in earlier comments

it is NOT possible to get the values using

1. var_dump($array[1]);

or

2. var_dump($array['1']);

or

3. var_dump($array[1]);

or

4. $k = array_keys($array);
   var_dum($array[$k[0]]);

All of these options will result into undefined index.

Even though the keys we convertet to strings, you cant get the values by using 
the string key. You cant even get the value if you get the keys by array_keys() 
first. Before posting something about string keys vs int keys now, just take a 
close look at 4.

best regards


Previous Comments:

[2012-09-04 13:17:45] larue...@php.net

they are the same

the array's key 1 has become to string 1..


[2012-09-04 11:39:27] janfili+phpbugs at gmail dot com

not similar to https://bugs.php.net/bug.php?id=51915

51915 mentions that the indexes become strings, and that is the case of course 
through json en/decoding.

The bug described in this ticket is that the elements belonging to these keys 
are not retrievable anymore. 

even if you explicitly get the keys

$k = array_keys($array);
echo $array[$k[0]];

will result in undefined index. Reductio ad absurdum


[2012-09-04 11:17:17] larue...@php.net

similar to https://bugs.php.net/bug.php?id=51915


[2012-09-04 08:21:08] reeze dot xia at gmail dot com

Yes, it will not accessible anymore if you have property with string number.
since array handle keys different from objects.


[2012-09-04 08:19:17] reeze dot xia at gmail dot com

Ah, I'm sorry, the bug ID: #54082, I can't find the report right now.

will post that later




The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

https://bugs.php.net/bug.php?id=63007


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63007edit=1


Bug #63007 [Com]: json functions corrupt arrayindizes

2012-09-04 Thread reeze dot xia at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=63007edit=1

 ID: 63007
 Comment by: reeze dot xia at gmail dot com
 Reported by:janfili+phpbugs at gmail dot com
 Summary:json functions corrupt arrayindizes
 Status: Not a bug
 Type:   Bug
 Package:JSON related
 Operating System:   Linux ubuntu1010
 PHP Version:5.3.16
 Block user comment: N
 Private report: N

 New Comment:

Hi janfili, 
   It IS a bug, @see https://bugs.php.net/bug.php?id=61655
object - array have problem, so does array - object have the same problem.

It is inconsistent, but it was documented.


Previous Comments:

[2012-09-04 14:37:23] larue...@php.net


would you read my comment clearly(or the comment of  scott...@php.net in 
#51951)?

as I said, the key has become to a string...

I knew what you are saying, but as I said, it's a knew behavior(or knew 
issue)...


[2012-09-04 14:16:03] janfili+phpbugs at gmail dot com

Would you please read my comments carefully again?

as i mentioned in earlier comments

it is NOT possible to get the values using

1. var_dump($array[1]);

or

2. var_dump($array['1']);

or

3. var_dump($array[1]);

or

4. $k = array_keys($array);
   var_dum($array[$k[0]]);

All of these options will result into undefined index.

Even though the keys we convertet to strings, you cant get the values by using 
the string key. You cant even get the value if you get the keys by array_keys() 
first. Before posting something about string keys vs int keys now, just take a 
close look at 4.

best regards


[2012-09-04 13:17:45] larue...@php.net

they are the same

the array's key 1 has become to string 1..


[2012-09-04 11:39:27] janfili+phpbugs at gmail dot com

not similar to https://bugs.php.net/bug.php?id=51915

51915 mentions that the indexes become strings, and that is the case of course 
through json en/decoding.

The bug described in this ticket is that the elements belonging to these keys 
are not retrievable anymore. 

even if you explicitly get the keys

$k = array_keys($array);
echo $array[$k[0]];

will result in undefined index. Reductio ad absurdum


[2012-09-04 11:17:17] larue...@php.net

similar to https://bugs.php.net/bug.php?id=51915




The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

https://bugs.php.net/bug.php?id=63007


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63007edit=1


Bug #63007 [Com]: json functions corrupt arrayindizes

2012-09-04 Thread janfili+phpbugs at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=63007edit=1

 ID: 63007
 Comment by: janfili+phpbugs at gmail dot com
 Reported by:janfili+phpbugs at gmail dot com
 Summary:json functions corrupt arrayindizes
 Status: Not a bug
 Type:   Bug
 Package:JSON related
 Operating System:   Linux ubuntu1010
 PHP Version:5.3.16
 Block user comment: N
 Private report: N

 New Comment:

This is a real duplicate:

 https://bugs.php.net/bug.php?id=45959

And it ended in fixing the Documentation.
What is fine. But the Documentation did
 not get Update everywhere.

This page covers it just fine.

 http://www.php.net/manual/en/
language.types.array.php#language.types.arr
ay.casting 
 
But this one doesnt

 http://www.php.net/manual/de/
language.types.array.php#language.types.arr
ay.casting


I see the language parameter in the url, but it in english all the time.
Can someone make all the pages up to date.


Previous Comments:

[2012-09-04 14:38:20] reeze dot xia at gmail dot com

Hi janfili, 
   It IS a bug, @see https://bugs.php.net/bug.php?id=61655
object - array have problem, so does array - object have the same problem.

It is inconsistent, but it was documented.


[2012-09-04 14:37:23] larue...@php.net


would you read my comment clearly(or the comment of  scott...@php.net in 
#51951)?

as I said, the key has become to a string...

I knew what you are saying, but as I said, it's a knew behavior(or knew 
issue)...


[2012-09-04 14:16:03] janfili+phpbugs at gmail dot com

Would you please read my comments carefully again?

as i mentioned in earlier comments

it is NOT possible to get the values using

1. var_dump($array[1]);

or

2. var_dump($array['1']);

or

3. var_dump($array[1]);

or

4. $k = array_keys($array);
   var_dum($array[$k[0]]);

All of these options will result into undefined index.

Even though the keys we convertet to strings, you cant get the values by using 
the string key. You cant even get the value if you get the keys by array_keys() 
first. Before posting something about string keys vs int keys now, just take a 
close look at 4.

best regards


[2012-09-04 13:17:45] larue...@php.net

they are the same

the array's key 1 has become to string 1..


[2012-09-04 11:39:27] janfili+phpbugs at gmail dot com

not similar to https://bugs.php.net/bug.php?id=51915

51915 mentions that the indexes become strings, and that is the case of course 
through json en/decoding.

The bug described in this ticket is that the elements belonging to these keys 
are not retrievable anymore. 

even if you explicitly get the keys

$k = array_keys($array);
echo $array[$k[0]];

will result in undefined index. Reductio ad absurdum




The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

https://bugs.php.net/bug.php?id=63007


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63007edit=1