on 03-07-2015 9:50 AM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.