I seemed to be stuck with JSON Decode , i dont know how to decode the json object or maybe im doing something very wrong , iam doing :
$error_fields_structure['product_id'] = $this->input->post('product_id');
$error_fields_structure['main_product_quantity'] = $this->input->post('quantity');
$error_fields_structure = json_encode($error_fields_structure);
i pass $error_fields_structure to my view and in my java script i do:
<?php print_r(json_decode($error_fields_structure)); ?>;
i get an error in firebug and following output
stdClass Object
(
[product_id] => 62
[product_quantity] => 65
);
but if i do
<?php print_r(json_decode($error_fields_structure['product_id'])); ?>;
it gives me a null string and an error
how do i get particular product_id and product_quantity from json object $error_fields_structure
You can only decode a valid json string.
is incorrect as $error_fields_structure[‘product_id’] is not a json string.
Try this :
or