In this application, one of the nested results of my JSON return I need is a string that looks like the following:
"<Money amount="25" currencyCode=""/>"
How would I pull out the Money amount to display in a model/collection?
Thanks!
In this application, one of the nested results of my JSON return I need is a string that looks like the following:
"<Money amount="25" currencyCode=""/>"
How would I pull out the Money amount to display in a model/collection?
Thanks!
Backbone provides a parse method that will me called if provided at the time to fetch http://backbonejs.org/#Model-parse
so in your model definition convert the xml to json and set the json values to the model
var Amodel = Bakcobone.Model.extend({
parse : function (response) {
// here you parse your xml and once is converted to json you can set the values to the model
return parsed response.
}
});
to parse the xml to json please taka a look a the following question. Convert XML to JSON (and back) using Javascript