I have json string in database
{"api":[{"caseid":2,"fullname":"df","businessname":"asdf","phonenumber":"12345678","activity":"sdf","province":7,"wilayat":"adfasd","description":"sfasdf","casedate":"2018-02-08 11:39:19"},{"caseid":3,"fullname":"\u0646\u0648\u0631\u062e\u0627\u0646 \u062a\u0627\u062a\u0627\u0631\u064a","businessname":"\u0627\u0644\u0631\u0641\u062f","phonenumber":"98818663","activity":"\u0646\u0649\u0633 \u064a\u0634\u064a \u0647\u062e\u0634 \u0645\u062a \u0634\u064a\u0628\u0634\u0633","province":1,"wilayat":"\u0627\u0644\u0633\u064a\u0628","description":"\u0648\u0635\u0641 \u0627\u0644\u0634\u0643\u0648\u064a","casedate":"2018-02-08 12:14:24"},{"caseid":4,"fullname":"test","businessname":"asdf","phonenumber":"12345678","activity":"asdfas","province":3,"wilayat":"dfasdf","description":"fsdfasdfasdf","casedate":"2018-02-08 12:24:53"},{"caseid":5,"fullname":"\u0645\u062d\u0645\u062f \u0627\u0633\u0644\u0627\u0645","businessname":"\u0635\u0646\u062f\u0648\u0642 \u0627\u0644\u0631\u0641\u062f","phonenumber":"98818663","activity":"\u0649\u0646 \u0633\u0634 \u0646\u062e \u0645\u0643 \u0648\u0646\u062e \u0635\u062e\u0636 \u062d\u062e\u0634","province":1,"wilayat":"\u0627\u0644\u0633\u064a\u0628","description":"\u0634\u0628 \u0634\u0633\u064a\u0628 \u0634\u0633\u064a\u0628 \u0634\u0633\u0628 \u062b\u0636\u0635 \u0631\u062b\u0631\u062b \u0631\u062b\u0631\u0631 \u0629\u0645 \u0629\u0648\u0648 \u0646\u0646\u062e\u062d","casedate":"2018-02-12 11:23:38"},{"caseid":6,"fullname":"\u0641\u0647\u062f \u0627\u0644\u062d\u0627\u0631\u062b\u064a","businessname":"\u062a\u062c\u0631\u0628\u0629 \u0627\u0644\u0646\u0638\u0627\u0645 ","phonenumber":"95871817","activity":"\u0644\u0627 \u064a\u0648\u062c\u062f ","province":1,"wilayat":"\u0627\u0644\u0633\u064a\u0628 ","description":"\u062a\u062c\u0631\u0628\u0629 1 ","casedate":"2018-02-13 13:40:51"}]}
$apiContent have above json string
$apiContent = $this->db->from("users_api")->get()->row()->apicontent;
when i write echo $apiContent it's shows the whole string but when i try to decode json string it's shows nothing
print_r(json_decode($apiContent, TRUE));
here is my whole function
function saveImportComplaint($xp)
{
$apiContent = $this->db->from("users_api")->get()->row()->apicontent;
return json_decode($apiContent, TRUE);
}
After adding makejsonsafe function i can read and convert json, error coming because of unicode value
function makejsonsafe($myjsonstring)
{
for ($i = 0; $i <= 31; ++$i)
{
$myjsonstring = str_replace(chr($i), "", $myjsonstring);
}
$myjsonstring = str_replace(chr(127), "", $myjsonstring);
if (0 === strpos(bin2hex($myjsonstring), 'efbbbf'))
{
$myjsonstring = substr($myjsonstring, 3);
}
$myjsonstring = json_decode( $myjsonstring );
return $myjsonstring;
}