I met a really strange problem.
Here is the problem:
Im using php 5.2's json extension. For example: I have a php variable $php_objects_array, which is an array with Objects I defined myself.
More specific, for example:
Code: Select all
<?php
class foo
{
var id;
var value;
}
?>Now, we want to encode this array into json so that I could pass it to javascript. Here is what I did:
$json_I_need =json_encode($php_objs_array)
now the string $json_I_need will be like: [{"id":"1","value":"45"},{"id":"2","value":"50"}]
when I pass this variable to javascript function, <javascript: test_f($json_I_need) >
I don't know how I can access this json objects, because it doesn't have members. In firebug, it just shows json_i_need has two objects, but when I tried json_i_need.Object[0].id, it always says that undefined references.
Please help! Thanks a lot!