for example my json string is like this :
{
"v1" : [],
"v2": 2,
"v3": f()
}
Now the context in which I need to decode this has a definition of f and f() gives right answer in that context(checked via debugger). But JSON.parse(jsonstring) gives me Unexpected token. eval also gives error. What should I do?
See an example Here
Why it does not work
Look at the definition of a JSON, it can not contain function calls.
Possible workarounds
One way is to do something like this, return a string of the function you want to call.
Now when you need to access it, you can call the function.
Other option is to change how your code works and make an async script call [jQuery would be
getScript, regular JavaScriptcreateElement("script")withappendChild()and use a callback like JSONP does.