PDA

View Full Version : Tip: Do not return columns that start with an underscore ('_') in your JSON Responses



aek82
16 Aug 2007, 4:18 PM
After a long debugging session, I found out that the Ext.data.JsonReader breaks when reading Json strings with column names that start with an underscore.

For example, the following will Json string returned will break your reader.



{ 'results': 2, 'rows': [
{ 'id': 1, 'name': 'Bill', _Occupation: 'Gardener' },
{ 'id': 2, 'name': 'Ben', _Occupation: 'Horticulturalist' } ]
}

After removing the underscores, the JsonReader worked.

Symptoms of problem:

After loading the data Store, the callback assigned to the 'load' event would not execute when calling the function '.load({ callback: handerObject})' or calling '.load()'. Calling '.getCount()' or '.getTotalCount()' yielded a count of 0 despite receiving a JsonResponse from the server and seeing the '.load()' function execute.

Hopefully this spares anyone the troubles to figure this out.

-Alex