i created a simple modifier to decode a string that is encoded in json.
function smarty_modifier_json_decode($string)
{
return json_decode($string, true);
}
Now i have somewhere into my database a string like this:
[{"foo": "bar bar", "cool": "attr"},{"foo": "bar", "cool": "attr"},{"foo": "bar", "cool": "attr"}]
The problem is the following if i store the above string locally inside the php file in a string variable and after i run the json_decode i get back the array i should get back and works fine.
But for some reason that i dont know and idont udnertand the string that is stored into the database is probably not correctly saved in the correct character encoding, because i always get back NULL when i try to execute the fucntion on smarty:
{$data.custom6|json_decode|var_dump}
So my question is if i have this string, but i dont know how my software save it into the database what should i do to convert it into the correct encodinh and after process it with json_decode ?
Thanks
NOTE 1: i dont know how the backend is saving data into the database and i cnnot influence this step. i can only using a web interface insert my JSON string in the custom field and press a SAVE button –
NOTE 2: sorry for the mistake copying the file here, i placed $json instead $string. But it doesnt work.