Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

JSON Parse Error, Start tag expected: Bug in 1.5? Or coding error?

There are a few other recent posts regarding this issue (ie, http://developer.appcelerator.com/question/80551/json-http-requests-always-log-message-about-parsing-error) but none seem to be addressed/solved/confirmed. I'd like to know if this is a known bug or a problem with my code…

I am using the HTTPClient to fetch and parse JSON. This works just fine, however the following info message gets logged to the console:

Entity: line 1: parser error : Start tag expected, '<' not found

I am using JSON.parse(this.responseText) inside the xhr.onload() method.

Also, the following error gets logged to the console:

[ERROR] Error Domain=com.google.GDataXML Code=-1 "The operation couldn’t be completed. (com.google.GDataXML error -1.)". in -[TiDOMDocumentProxy parseString:] (TiDOMDocumentProxy.m:50)

I tried setting the request header as follows but it does not resolve the issue:

xhr.setRequestHeader('Accept', 'application/json');

Again, the JSON is being parsed correctly and everything is working fine, it's just that I get a bunch of extraneous info and error messages logged to the console. Has anyone solved this? Or is this a known bug with the recent 1.5 nightly build?

— asked December 7th 2010 by Slim McKinsley
  • gdataxml
  • json
  • parse

1 Answer

  • Hi Slim,

    I have this issue as well. I've tried the following to no avail:

    • set the request header in the app.
    • confirmed that the content_type is correctly set as "application/json" for the document on the server.
    • set the document extension to .json on the server.
    • commented out everything in client.onload (which contains JSON.parse(this.responseText)).
    • changed the encoding on the document itself (for example, from utf-8 to Western (Windows Latin 1)).
    • saved the document as ASCII text using a different text editor.

    So I would think this is a bug with the recent 1.5.0 nightly builds. The issue is that, as soon as it's loaded, the document is being parsed as xml (since the error occurs even when JSON.parse is commented out).

    I can confirm that the Twitter demo in Kitchen Sink also has this issue.

    I know this doesn't really help, but hopefully sheds some more light on the problem.

    — answered December 7th 2010 by Da'oud Rashid
    1 Comment
    • Thanks for the feedback. Hopefully the Appcelerator devs will shed some light on this issue for us all.

      — commented December 7th 2010 by Slim McKinsley
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.