Unsolved How to assign ListModel's data to JsonObj in JS
-
Hi everyone,
How to assign ListModel's data to JsonObj in JS code to be saved to JSON file
I made something like thisListModel{ id: jsonDataModel; } JsonStorage{ //registered type id: jsonStorage fileName: "db" } function savJSON() { var jsonObj = listModel // here's the problem, how this assignment could be made ? var data = JSON.stringify(jsonObj) jsonStorage.save(data)
}
-
@Anas-A.-Ismail Assign the
ListModel
'sid
to that variable. Then you will need to iterate the model and stringify the individual data. Eg.:var model = jsonDataModel for(var a=0; a<model.count; a++) { console.log(JSON.stringify(model.get(a))) }
Then you can somehow aggregate all the data into a single string and pass it to your function.