decode json field not working

Hi all,

I'm working on a custom module and I need to save a json object in a field. I can save the json_encode in field long text but when I retrieve the field via BeanFactory and decode it, PHP Json return an error 4 of "Syntax Error"

Printing json_decode result and testing on a web json validator it seems ok.

Any Idea?

  • HI All,

    after trying some tricks I solved by myself. I simply encoded/decoded htmlspecialchars before saving and after retrieving data.

    This is the code:

    $my_bean->json_content = htmlspecialchars(json_encode($array_object), ENT_QUOTES, 'UTF-8');

    and then

    $myvar= htmlspecialchars_decode($array_object['json_content']);

    Thank you everybody.

    Bye!