Skip to Content
Former Member
Jun 25, 2015 at 04:32 AM

How to read JSON data which is coming from server and store in local variable in SAP UI5?


Hello Experts,

I am not able to read the JSON data which is coming from server and I would like to store one value into local variable? It is working fine if I bind the same model to UI controller ,the data is displaying correctly.But I need store one value into local variable.

Here is my code:

var oModelData = new sap.ui.model.json.JSONModel();

var root = window.location.protocol + '//' +;

var url = root + "/idmrest/v72alpha/entries/0";


this.getView().setModel(oModelData, "model1");

var zkey = this.getView().getModel("model1").getProperty("/ENTRIES/MSKEYVALUE/VALUE");

and It is saying "undefined" and if I use:

var zkey = oModelData.getProperty("/ENTRIES/MSKEYVALUE/VALUE");

here also it is undefined

can any body please suggest me here? and also how do we get the array and loop it which is inside the JSON (model1)?