I need to put a JSON object into an attribute on an HTML element.
The HTML does not have to validate.
Answered by Quenti
You can use knockoutjs,
First name: todo
Last name: todo
knockout.js
// This is a simple *viewmodel* - JavaScript that defines the data and behavior of your UI
function AppViewModel() {
this.firstName = "Jayson";
this.lastName = "Monterroso";
}
// Activates knockout.js
ko.applyBindings(new AppViewModel());
Output
First name: Jayson Last name: Monterroso
Check this: http://learn.knockoutjs.com/