1

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

4

1 回答 1

3

Redmine 返回有效的 JSON(可以在此处检查),因此 ExtJS JSON 阅读器可以毫无问题地读取它。

您只需要通过在阅读器上设置root属性 (ExtJS 4) 或rootProperty属性 (ExtJS 5) 来告诉他在哪里搜索。

ExtJS4:

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

ExtJS5:

reader:{
    type:'json',
    rootProperty:'issues'
}
于 2015-03-24T14:07:11.023 回答