On 3/2/11 5:52 AM, Jonas Sicking wrote:
I'm not quite sure what you mean by "via JSON" given that JSON is a serialization format.
The idea would be to take the input object, sanitize it by doing obj = JSON.parse(JSON.serialize(obj)); (which will get rid of crud like getters), and then work with it.
1. Don't allow getters, i.e. if the object contains any getters, throw an exception
This seems like the simplest solution.
2. Run getters and define in which order they are retrieved
This can get pretty hard to specify (esp. because it involves describing what happens if those getters reenter the API you're defining).
3. Treat getters as undefined
That doesn't seem like a good idea to me, honestly. -Boris