Forums » Developers



Invalid JSON output

Hello.

I just started using the Clicky API. I'm attempting to parse the output of type JSON using Ruby on Rails. It looks like the JSON that's being returned by the API is invalid. Here's an example of what's returned:

[ {value:'4',value_percent:'0.8',title:'address',clicky_url:'http://getclicky.com/stats/visitors?site_id=xxxxx&date=2008-07-07&search=address'}]

According to JSON dot org all values of type string must be wrapped in double quotes not single quotes. Here's the relevant quote:

A value can be a string in double quotes, or a number, or true or false or null, or an object or an array. These structures can be nested.

If this could be addressed, it would be appreciated.

Thanks.

Pat

Posted Mon Jul 7 2008 7:59a by innovec***


Since when is it illegal to wrap a string in single quotes? That seems ridiculous.

Will RoR not parse it?

Posted Mon Jul 7 2008 2:16p by Your Friendly Clicky Admin


Honestly, I thought that it was perfectly legal to wrap the value in a single quote. Not until both RoR's built-in json parser and the JSON plugin choked on the data I got from the Clicky API did I do some research and find the JSON.org specs.

Posted Fri Jul 11 2008 7:34a by innovec***


I also have a problem with parsing Clicky's JSON output. According to json.org, all identifiers (here: value, value_percent, title, clicky_url etc.) are strings and therefor must be quoted, like {"value": "4", "value_percent": "0.8"...}

Could you change this?

Posted Tue Aug 26 2008 6:47p by fneuma***


Ok, API v3 has been updated to wrap all keys and values in double quotes. Sorry about any problems that was causing.

My personal opinion, this is a horrible spec. There is no Javascript requirement that I know of that says strings must use double quotes. And, JSON "keys" are really "properties" of an object, which are normally declared without quotes in Javascript.

But whatever. Hopefully this makes the results work better with existing parsers!

Posted Sat Aug 30 2008 10:47a by Your Friendly Clicky Admin


It sure does make the results harder to read, too. I spent a damn long time making the JSON output well formatted so it was easy to read. This pretty much kills that :(

Posted Sat Aug 30 2008 10:49a by Your Friendly Clicky Admin


New to this - any guidance?

Posted Fri Sep 2 2011 4:30p by ***


As the tempareture inceasing hot day after day, and the step of summer vocation is just around the corner, what plan do you made for your vivid summer?Swimming in the sea and hang about in the sand beach is a common plan year by year and one by one. Maybe you can travel around the ice island or going to an icy palace to enjoy with all your heart with different scenery. Or you can stay at home to participate in Diablo III. It is very popular at the moment and Diablo series is a legend. What do you think about? [b][url=http://www.diablo3buygold.com]Buy Diablo 3 Gold[/url][/b]

Posted Fri Jun 15 2012 4:29a by ***


You must be logged in to your account to post!