Ext.data.JsonReader - pass Json directly - Ext JS

First, i LOVE the JsonReader in the Data class! Awesome work, this is going to make things much easier to build. Nice work!

One suggestion:

In JsonReader.js, I notice that you can only pass a response:

Ext.extend(Ext.data.JsonReader, Ext.data.DataReader, {
    read : function(response){
        var json = response.responseText;
        var o = eval("("+json+")");
        if(!o) {
            throw {message: "JsonReader.read: Json object not found"};
        }
        return this.readRecords(o);
    },
Is there a way you can also pass Json text?
I ask because I use another AJAX provider that can return Json already, and I would like to get that returned Json string and just pass it directly to the JsonReader. In my scenario, I have already handled the response.responseText, and I already have the Json located in a string. I'd like to be able to call the JsonReader and just pass the Json string.

Possible for a future release?

Thanks!

-- W.G.
  # 2  
03-08-2007, 01:38 PM

I assume that means you're not going thru the proxy classes, so you could just eval your json string into an object and pas that to readRecords() instead of calling read()
__________________
Tim Ryan - Ext JS Support Team
Read BEFORE posting a question / posting a Bug
Use Google to Search - API / Forum
API Doc (3.x | 2.x | 1.x) / FAQ / Wiki / Tutorials / 1.x->2.0 Migration Guide
  # 3  
03-08-2007, 01:46 PM

By George, that's true.. I could just eval my returned Json and pass to readRecords.

I love this forum, everyone is so enthused and offers such great insight. I've learned more about JavaScript in the last two months than I have in the last 4 years.

Thank you!

-- W.G.
  # 4  
03-08-2007, 05:41 PM

Also, if it's going into a Store, you can eval the response and pass it to store.loadData(obj) and everythng in the store will get updated appropriately.

你可能感兴趣的:(JavaScript,json,Ajax,ext,Google)