munder
munder

Reputation: 137

Sencha Touch 2 returns acceptable json; phonegap rejects it

Running my Sencha 2 app in Chrome, I have a store with a rest proxy and a reader of type json. The store fetches data from a web service and the returned json is:

{"user":{"distributionRespondentId":"71","loginId":"01000368_95655233_71","remoteId":"90","name":"Tycho Brahe","companyId":1000368,"companyName":"MickTest3","pin":"60075826"}}

which, according to JsonLint, is fine and the Sencha 2 app running in Chrome is quite happy with it.

I have eclipse set up with Applaud and put my Sencha 2 app in the assets/www directory. When I debug it on an Android device, Sencha coughs over the json, reporting:

file:///android_asset/www/touch/sencha-touch-all.js: Line 106299 : [WARN][Ext.data.reader.Reader#process] Unable to parse the JSON returned by the server: SyntaxError: Unexpected token ILLEGAL

That doesn't make a lot of sense to me. Any suggestions anybody?

Upvotes: 1

Views: 411

Answers (1)

oshevans
oshevans

Reputation: 116

I had a similar problem with a different setup, but essentially the same error. Where frustratingly my JSON was also validating fine, but the app just didn't like it.

'Unexpected tocken ILLEGAL' - yeah thanks for the detailed error message Mr Debugger.

The issues was that I had unescaped characters within my content (e.g. HTML content, single quotes, etc.). Once I cleaned up the source coming from the server my app was happy to parse it as JSON.

Upvotes: 1

Related Questions