how to configure extjs reader to read this json?

前端 未结 2 1790
野的像风
野的像风 2021-01-15 15:59

I\'ve configured extjs store to load data from useragentstring.com api, this api return data like this

{\"agent_type\":\"Browser\",\"agent_name\":\"Opera\",\         


        
2条回答
  •  醉话见心
    2021-01-15 16:14

    You need to restructure your json object that is returned to look more like:

    {
        root:  {     
          "agent_type":"Browser",
          "agent_name":"Opera",
          "agent_version":"9.70",
          "os_type":"Linux",
          "os_name":"Linux",
          "os_versionName":"",
          "os_versionNumber":"",
          "os_producer":"",
          "os_producerURL":"",
          "linux_distibution":"Null",
          "agent_language":"English - United States",
          "agent_languageTag":"en-us"
       }
    }
    

    When you define the root of your JsonReader, you are telling the reader where in the object it should look. This is done so that you can return multiple objects inside your JSON for different stores on the same request.

    As a side note you may want to watch how you handle Null values from your PHP... You may find that you will need to handle replacing "Null" from the backend as I believe ExtJS will treat "Null" as a string.

提交回复
热议问题