Fork me on GitHub


GitHub Core

Show your support for Zikula! Sign up at Github account and watch the Core project!

GitHub Modules

Forum Activity

Forum feed

» Visit forum | » View latest posts

JSON Parsing error  Bottom

  • On a zikula 1.2.x site I have I am trying to do some js controls. I have an array of data that I need encoded as JSON. There are quotes in the data, so prior to encoding I have escaped the data in the array using

    array_map('mysql_real_escape_string', $array);

    To encode, I am doing:


        $json = new Services_JSON();
        $output = $json->encode($array);

    However I am getting a parse error on the results. I have tested the encoded JSON at:

    and it passes as valid.

  • What does the error display exactly?
  • "JSON Parse error"
  • So I have discovered that the data causing the problem is an element in an array

    "current number" => int() 1

    Changing it to a string eliminates the parse error.

    I am probably revealing my ignorance here, but integers aren't allowed in JSON? I have googled various versions of that question, and it seems they are. I am OK with converting this item into a string, but I want to understand what the real issue is here.

  • It's pretty weird indeed,
    the problem may be in the script that decodes the JSON response?

    If it passes the validation I don't see another source of the problem,
    but the encoding of the response, which is a tricky topic that I gave in the hands of ajax.php :P

    - Mateo T. -
    Mis principios... son mis fines

This list is based on users active over the last 60 minutes.