php - json_decode() expects parameter 1 to be string, array given? -
this data ,after json_encode()
array ( [{"customerid":"1","customer_name":"jon_doe","amount":"12312312","billcode":"b1231","billname":"cashbilname","billcategorycode":"1234","billcategory":"utility","month":"may","year":"2015","txcode":"10","stationid":"152","station":"coroom","operatorcode":"1200","operator":"jame","terminal":"ter12312","txdate":"12\/2\/2015","txtime":"12:21:22_pm"}] => )
now want decode ,by applying json_decode()
gives following error
json_decode() expects parameter 1 string, array given
any idea sugestion ?
your json
must in string
, not in array
$json_string = '{"a":1,"b":2,"c":3,"d":4,"e":5}'; $json_array = json_decode($json_string); $json_array : array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
if json
in array
can :
$json_string_in_array = array('{"a":1,"b":2,"c":3,"d":4,"e":5}'); $json_array = json_decode($json_string_in_array[0]);
Comments
Post a Comment