cancel
Showing results for 
Search instead for 
Did you mean: 

Get value of node from Json output

neha1620
Explorer
0 Kudos
177

Hi Experts,

I am using json model in irpt page.

My output looks like:

{ "Rowsets" : {

"DateCreated" : "2023-10-26T22:31:58", "Version" : "15.5 SP0 Patch 25 (May 26, 2023)", "StartDate" : "2023-10-26T21:31:58+0200", "EndDate" : "2023-10-26T22:31:58+0200", "CachedTime" : "",

"Rowset" : [

{ "Columns" : {

"Column" : [

{ "Name" : "Output", "SourceColumn" : "Output", "Description" : "", "SQLDataType" : 1, "MinRange" : 0.0, "MaxRange" : 0.0 } ] },

"Row" : [

{ "Output" : "Invalid input value/s: 21" } ]

} ]

I want extract tag "Output" and alert its value in page.

My code in controller is:

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

oModel.loadData("/XMII/Illuminator?QueryTemplate=Qry&Param.1=" + site + "&Param.2=" + selectedinputValue + "&Param.3=" + inputval + "&Content-Type=text/json", "POST", false);

var getRows = oModel.getData().Rowsets.Rowset[0].Row.Output;

oModel.setData({

modelData: getRows

});

console.log(oModel.getProperty("/Rowsets/Rowset[0]/Row"));

this.getView().setModel(oModel);

Value of console log is showing as undefined.

How can I extract value of "Output" tag?

Thank you in advance.

Regards,

Neha

View Entire Topic
junwu
Active Contributor
0 Kudos

how about console.log(oModel.getProperty("/modelData"));?

neha1620
Explorer
0 Kudos

Hi @Jun Wu,

It still gives same undefined error.

Is any other way to access data?

Thanks,

Neha

junwu
Active Contributor
0 Kudos

var getRows = oModel.getData().Rowsets.Rowset[0].Row.Output;

did you get any data there when you debug?