cancel
Showing results for 
Search instead for 
Did you mean: 

JSON model and OData model

09-07-2015 8:21 AM
763 views 3 comments
0 Likes
SAP Managed Tags
Subscribe

Hi all,

I have a question.

What's the diff between JSON model and Odata model(JSON format).

If I need a JSON model from back-end, can I just use JQuery/AJAX instead of using UI5 OData APIs?

0 Likes

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member182372
Active Contributor
0 Likes

>>If I need a JSON model from back-end, can I just use JQuery/AJAX instead of using UI5 OData APIs?


If you need to use plain JSON data from backend you will not be able to use odata model as there is no metadata.


in case of odata with json format ($format=JSON) you can use jquery ajax, you just have to explicitly handle xsrf token

santhu_gowdaz
Active Contributor
0 Likes
xyla
Participant
0 Likes

Hi,

the two models have different features when it comes to data handling. The JSONModel is better for client-side data container, because you can very easily add, remove entrys. The ODataModel has nice features when it comes to data transfer between the client and server. Based on the binding you make to a control, it makes automatic requests to the server for getting data. You can also add filters, expand deep entities, etc. I suggest you take a look at the APIs of the two models.

JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.model.json.JSONModel

JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.model.odata.v2.ODataMod...

Yes, you can also use JQuery/AJAX,like this:


jQuery.ajax({

   type :'POST',

   url : yourURL,

   headers : oHeaders,

   cache : false,

   contentType : yourContectType,

   processData : false,

   data : yourDataObject,

   success : _handleSuccess,

   error : _handleError,

   });