Abdul Rehman Yawar Khan
Abdul Rehman Yawar Khan

Reputation: 1087

Redmine returns JSON with word "issues" padded in start

I have setup Redmine locally. I want to Get and Post data on Red mine in order to test my Extjs application. Redmine RestApi support is available. This link show all the issue on Redmine available http://www.redmine.org/issues.json

Problem is that it is padded with word "issues" due to which I can't read it via simple Json type reader in Extjs. I guess JSONP can provide some solution but I am not able to figure out how? Can any help by telling how to get simple JSON without and padded word?

Here is my Extjs app Model:

Ext.define('ThemeApp.model.peopleModel', {
extend: 'Ext.data.Model',

fields: [
    { name: 'id' },

    { name: 'subject' },

    { name: 'description'}
],

proxy: {
    type: 'rest',
    format: 'json',
    limitParam:"",
    filterParam: "",

    url:'http://www.redmine.org/issues.json',

    //headers: {'Content-Type': "application/json" },
    //url : 'http://api.soundcloud.com/tracks?q=allah%20dita%20rehman%20khan&client_id=0b19b8dc2526b43eae19f03b2eab6798&format=json&_status_code_map[302]=200'

    reader: {
    type: 'json',
    rootProperty:'issues'
    },
    writer: {
        type: 'json'
    }

}});

Error in Browser Console is Browser Error

Upvotes: 1

Views: 195

Answers (1)

Alexander
Alexander

Reputation: 20244

Redmine returns valid JSON (as can be checked here), so the ExtJS JSON reader can read it without a problem.

You will just have to tell him where to search, by setting the root property (ExtJS 4) or the rootProperty property (ExtJS 5) on the reader.

ExtJS4:

reader:{
    type:'json',
    root:'issues'
}

ExtJS5:

reader:{
    type:'json',
    rootProperty:'issues'
}

Upvotes: 3

Related Questions