Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Issue loading Json data : parsererror

Hi,

In my application i need to load data from Json file to display in dropdown but getting below error -

Error -

The following problem occurred: parsererror - {

Card: [

{Description: "Switch", enabled: true},

{Description: "Master", enabled: true},

{Description: "VISA", enabled: true},

{Description: "Default", enabled: true},

    ]

}

,200,OK 

My code is below -

// Create instance of JSON model

     oCardModel = new sap.ui.model.json.JSONModel();

  // Load JSON in model   

     oCardModel.loadData("models/Card.json");   ==========> (json file is available at WebContent/models/Card.json location)

//Card Type  

     var oCardType = new sap.ui.commons.DropdownBox({

      id: "CardType",

      tooltip: "Card Type",

      });

    

     var oListCard = new sap.ui.core.ListItem();

     oListCard.bindProperty("text", "Description");

     oListCard.bindProperty("enabled", "enabled")

    

     // Bind model to table control   

     oCardType.setModel(oCardModel);

    

     oCardType.bindItems("/Card",oListCard );

Can someone please help.

Former Member
replied

Hi Swati,

use quotation marks for all values (also for the names).

{

    "Card": [

        {

            "Description": "Switch",

            "enabled": true

        },

        {

            "Description": "Master",

            "enabled": true

        },

        {

            "Description": "VISA",

            "enabled": true

        },

        {

            "Description": "Default",

            "enabled": true

        }

    ]

}

You can validate your JSON strings for example on JSONLint - The JSON Validator.

Best regards,

Florian

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question