2014-04-29 112 views
0

我需要使用Sencha Touch商店和模式連接到API。如何配置Sencha Touch 2商店,讀取多級json對象

的問題代表了API的響應JSON,這是類似的:

{ 
    "The_Api": { 
     "initSession":{ 
      "calledMethod":"The_Api::initSession", 
      "status":"1", 
      "error":"0", 
      "errorCode":"0", 
      "errorMessage":"", 
      "data":{ 
       "token":"api_535f6c5d68dc78.56464399" 
      } 
     } 
    } 
} 

我需要檢索此響應令牌值。

如何配置我的商店以獲取令牌值?

Ext.define('TestApp.store.SecretKeyStore', { 
    extend: "Ext.data.Store", 
    config: { 
     storeId: 'SecretKeyStore', 
     model: "TestApp.model.SecretKeyModel", 
     params: { 
      lang: 'FR', 
      method: 'initSession', 
      username: TestApp.utils.GlobalVariables.getUsername(), 
      secretKey: TestApp.utils.GlobalVariables.getSecretKey() 
     }, 
     proxy: { 
      type: 'ajax', 
      noCache: true, 
      url: '/rest_json.php', 
      remoteFilter:true, 
      reader: { 
       type: 'json', 
       rootProperty: 'data' 
      } 
     } 
    } 
}); 

我應該使用什麼樣的根屬性?

回答

0

它的一個js對象,因此這應該工作:

rootProperty:'The_Api.initSession.data'