json returning string instead of object

Posted by peter on Stack Overflow See other posts from Stack Overflow or by peter
Published on 2012-12-08T21:54:27Z Indexed on 2012/12/08 23:04 UTC
Read the original article Hit count: 230

Filed under:
|
|

i have

 $age = implode(',', $wage);   // which is object return:  [1,4],[7,11],[15,11]
  $ww = json_encode($age);

and then i retrieve it here

    var age = JSON.parse(<?php echo json_encode($ww); ?>); 

so if i make

   alert(typeof(<?php echo $age; ?>))   // object
   alert(typeof(age))                   //string

in my case JSON.parse retuned as string.

how can i let json return as object?

EDIT:

 var age = JSON.parse(<?php echo $ww; ?>); // didnt work , its something syntax error

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript