cancel
Showing results for 
Search instead for 
Did you mean: 

Issue loading Json data : parsererror

former_member602416
Participant
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

pfefferf
Active Contributor
0 Kudos

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

Answers (0)