Problem
I'm writing a javascript library for skeletal animations on canvas, and I want to be able to encapsulate entities as JSON data. For example, if I want to draw a minotaur, I simply fetch minotaur.json and it contains information about sprite sheets, bone angles, animations, etc. My problem is that I want library users to be able to hook into my "draw" function so that user functions can be called while the object is drawn (kind of like a primitive shader). For example, directional lighting or a red enraged effect can be implemented on individual sprites using such a hook. However, I want these hooks to be able to be encapsulated in my JSON object as well. The only way that I can think of to accomplish this is storing the functions as strings and then calling eval on them.
Question
Obviously, eval is evil, and I've never actually used it in code. Afaik there is no way to encapsulate a function in JSON. Is this actually a situation where eval is acceptable? Or is wanting to store these entities as JSON data a fool's errand?