cancel
Showing results for 
Search instead for 
Did you mean: 

OData format JSON

rubens12
Participant
0 Kudos

I am trying consume the OData format Json below, but I don't know what is the "path"

{"d":{"__metadata":{"id":"http://xxxx:xxxx/sap/opu/odata/sap/ZGW_TRANSF_APPROVAL_SRV_02/zget('xxxx')","uri":"http://xxxx:xxxx/sap/opu/odata/sap/ZGW_TRANSF_APPROVAL_SRV_02/zget('xxxx')","type":"ZGW_TRANSF_APPROVAL_SRV_02.zget_name"},"login":"RUBENS","name":"RUBENS"}}

Can someone help me to found the "path" in this Json?

former_member340030
Contributor
0 Kudos

Hi ,

What path you are saying here ??

thanks

Viplove

rubens12
Participant
0 Kudos

I want consume it in SAPUI5 to get the "login", I think I need know the path of the "login"

rubens12
Participant
0 Kudos

I want consume it in SAPUI5 to get the "login", I think I need know the path of the "login"

Accepted Solutions (0)

Answers (1)

Answers (1)

ChrisSolomon
Active Contributor
0 Kudos

This is pretty basic JSON info you can find in most any JSON tutorial....ie "how to reference elements in JSON?"

{
    "d": {
        "__metadata": {
            "id": "http://xxxx:xxxx/sap/opu/odata/sap/ZGW_TRANSF_APPROVAL_SRV_02/zget('xxxx')",
            "uri": "http://xxxx:xxxx/sap/opu/odata/sap/ZGW_TRANSF_APPROVAL_SRV_02/zget('xxxx')",
            "type": "ZGW_TRANSF_APPROVAL_SRV_02.zget_name"
        },
        "login": "RUBENS",
        "name": "RUBENS"
    }
}

so "login" would be...
['d']['login']

you can use this site too which will help you...
JSONPath expression tester

rubens12
Participant
0 Kudos

Hi Christopher,

I am trying consume this JSON in SAPUI5.

Below is my code

//call the OData
var sServiceUrl = "http://xxxx:xxxx/sap/opu/odata/sap/ZGW_TRANSF_APPROVAL_SRV_02";
			var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, true, "user", "pass");
			
			var oJsonModel = new sap.ui.model.json.JSONModel();


			oModel.read("/zget('RUBENS')", null, null, true, function(oData, response) {
				oJsonModel.setData(oData);

//set the items

items: {
						path: "/d",
						template: new sap.m.StandardListItem({
							title: "{name} ({login})",
							active: true
						})
					}



I run in eclipse and in ABAP server, but it is not get any data.