My ongoing struggle with stupidity and what is not valid JSON

So this was a frustrating lesson to learn – and please feel free to be entertained by my apparent stupidity.

I was trying to create my own JSON with an xAgent – seems easy enough. I created a simple output which looked like this

{
    'items': [
        {
            'name': 'AK',
            'dc': 23
        }
    ]
}

and when I fed it through my AJAX code it failed.

$.ajax({
	dataType: 'json',
	url: "http://copper.xomino.com/xomino/ExtjsBigData.nsf/xState.xsp?query="+query
	//url: 'http://copper.xomino.com/xomino/Extjs.nsf/xRestService.xsp/byFirstName?count=5'
}).done(function(data){
	console.log(data)
}).fail(function(e){
	console.log('FAIL')
	console.log(e)
})

But what was interesting is that it returned the data (e) correctly. I was baffled and frustrated for way too long.

So I finally asked he correct question of google (isn’t that always the case) and I found that http://jsonlint.com/ was telling me the strings were incorrect…..

because JSON requires double ” and not single ‘

really?

This worked – changed the single to double quotes.

{
    "items": [
        {
            "name": "AK",
            "dc": 23
        }
    ]
}

and I am apparently now less stupid that I was yesterday…….

PS

Kathy recommends – http://json.parser.online.fr/

4 thoughts on “My ongoing struggle with stupidity and what is not valid JSON

  1. Actually, it makes you less ignorant than yesterday. Ignorance is the lack of knowledge, stupid is the lack of capacity. Since we share a ‘lack of capacity’, I can’t fault you for a ‘lack of knowledge’, especially when you share that knowledge!

    Thanks, Marky!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s