in reply to Re: Javascript in your JSON
in thread Javascript in your JSON

I agree that putting scripts in a JSON structure is definitely not in the JSON standard. Even though JSON, before being a data-exchange standard, was just the run-of-the-mill javascript object notation in which script coderefs are perfectly acceptable.

The thing is that most ajax based frameworks, such as ExtJS, accept, or even recommend putting scripts in a JSON structure. So I guess I'll keep looking for a module that can dump that... or write my own.
cheers,
-- miguel

Replies are listed 'Best First'.
Re^3: Javascript in your JSON
by ikegami (Patriarch) on Apr 08, 2009 at 19:14 UTC
    A JSON file that includes arbitrary JavaScript code is not a JSON file, it's a JavaScript file. You should be looking for tools to help you generate JavaScript, not JSON.
Re^3: Javascript in your JSON
by derby (Abbot) on Apr 08, 2009 at 19:30 UTC

    I think it's really easy to confuse/conflate Javascript object literal notation with JSON - they're not the same thing.

    -derby

    Update: hmmm ... well that was vague. JSON is a subset of Javascript object literal notation that's used for *DATA* exchange. That's why if want to pass around function definitions in JSON, you'll need to de-stringify them - basically subverting the concept of JSON being just for *DATA* exchange.