Mike Thomsen
Mike Thomsen

Reputation: 37506

Why is this JSON "invalid?"

This JSON passes jsonlint validation. Yet Firefox and Chrome reject it:

{
    "messages": [
        {
            "subject": "One"
        },
        {
            "subject": "Two"
        },
        {
            "subject": "Three"
        }
    ],
    "totalResults": 10
}

The error message is "invalid label" on "messages."

This is how it is being loaded:

var store = Ext.create('Ext.data.Store', {
    model: 'MyModel',
    autoLoad: true,
    pageSize: 3,
    proxy: {
        type: 'jsonp',
        url: 'http://localhost:8080/document-viewer-1.0/testdata.json',
        reader: {
            root: 'messages',
            totalProperty: 'totalResults'
        }
    }
});

Answer:

It was my own stupid mistake. I didn't put the JSONP callback name around the JSON file structure.

Upvotes: 2

Views: 461

Answers (1)

Adam Rackis
Adam Rackis

Reputation: 83356

What you have is valid JSON, but it's not valid JSON P

You need to change

type: 'jsonp',

to

type: 'json',

Upvotes: 8

Related Questions