Skip to Content

UI5 Loading json file

I am attempting to load a structured json file (entity model) and then bind it to a view. Also have other views use part of that json object (entity set) as well, but that's getting ahead of myself as I can't even get a simply json structure loaded yet. I'm using Eclipse as an editor, if that matters, with my json file being in the webContent directory, and my controller being in webContent/controller directory. We have tabLayout set in the index.html to point to the webContent directory.

I simply can not get my json file to load, here's a section of my controller code:

var TableController = Controller.extend("tabLayout.controller.testcontroller", {

onInit: function () { 
var oMydata = new sap.ui.model.json.JSONModel(); 

When viewing in debug via chrome the odata section for oMydata shows no data.

I have also tried:


but with no joy.

If I manually declare it in the console it's working, using setData.

My json file is in the format:

  "oMydata": { 
			{ "field1": "xyz",   
		  	  "field2": "abc"  

If anyone can see the obvious then do please let me know.

I get no error, that I can see when using loadData. Is there a good way of trapping whether an error has occurred and displaying it?.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    Mar 08, 2017 at 06:28 PM


    file loading is aysnc. that's why you cannot get the data immediately after the data load call.

    you can make it as sync, you can supply second parameter value false; make sure have the right path to the file.

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 08, 2017 at 04:55 PM

    Check your network tab in Chrome to see if there is any request sent for JSON file

    I think the issue is related to path where JSON file is stored...can you show the screenshot of project structure..

    Alternatively you can instantiate JSON models directly from manifest.json (suggested way)

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 09, 2017 at 08:16 AM

    It is working as expected, please have a look on the below url.


    Karthik A

    Add comment
    10|10000 characters needed characters exceeded