Results 1 to 4 of 4

Thread: JSON parsing fails if single quotes are used?

  1. #1
    Ext JS Premium Member codeslice's Avatar
    Join Date
    Feb 2008
    Posts
    15

    Question JSON parsing fails if single quotes are used?

    Hi Folks,

    I have been happily using single quotes for my json under Ext.JS for a long time

    Doing my first page in Sencha Touch and notice that it seems to require double quotes?

    Has anyone else struck that?

    I thought that either single or double quotes were valid for json?

    This works

    {"total":"1","results":[{"siteID":"0285","siteName":"HIGH WYCOMBE"}]}

    This fails somewhere inside the load function. The beforeload event fires but I never see the load event.

    {'total':'1','results':[{'siteID':'0285','siteName':'HIGH WYCOMBE'}]}

    Thoughts?

    Regards

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449

    Default

    Single quotes are not valid JSON.

    http://www.jsonlint.com/
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3
    Ext JS Premium Member codeslice's Avatar
    Join Date
    Feb 2008
    Posts
    15

    Default

    Quote Originally Posted by mitchellsimoens View Post
    Single quotes are not valid JSON.

    http://www.jsonlint.com/
    Thanks. Back when I started with json there was no jsonlint (or at least I didn't know about it) and a search then turned up some saying single some saying double. Double it is.

  4. #4
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449

    Default

    No problem. jsonlint.com is a great site, I use it just so that it will indent my string so I can visualize it better :-)
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

Similar Threads

  1. Parsing a single json item
    By D-L in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 30 Jul 2013, 2:29 AM
  2. Replies: 1
    Last Post: 13 Dec 2008, 3:14 AM
  3. Problem with XTemplate and single quotes
    By rthibault in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 28 Apr 2008, 9:09 AM
  4. Escaping single quotes in an Ext form?
    By SSJSparky in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 15 Oct 2007, 12:21 PM
  5. Single vs Double Quotes??
    By Grimsk in forum Community Discussion
    Replies: 8
    Last Post: 30 Aug 2007, 3:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •