I'm writing a javascript animation script and I want people to be able to specify behaviour declaratively in the HTML.
This is what I want my HTML to look like:
<div data-animation="top: 600, left: 600, opacity: 1, start: 0.2, finish: 0.8"></div>
This obviously isn't valid JSON, but you can't write valid JSON in HTML. Is there a way to turn this into JSON?
I want to be able to get the attribute value and turn it straight into a javascript object that I can use without having to manually parse the string. I.e. I want this:
var example = {
top: 600,
left: 600,
opacity: 1,
start: 0.2,
finish: 0.8
};