Page 1 of 1

JSON API: Wrong string delimiter

Posted: August 12th, 2011, 6:47 pm
by WhatSAB
Hi there,

I am trying to use the JSON API (for history in SABnzbd 0.6.7) but all strings seem to be wrapped in single quotes. The JSON standard defines strings like this:
http://www.json.org
A string is a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes.
but it looks like this:
http://localhost:8081/api?mode=history&apikey=...
{'active_lang': 'de', 'paused': False, 'session':

This makes my JSON parser explode. Is this a bug? Am I doing something wrong?

Thanks for your help.

Re: JSON API: Wrong string delimiter

Posted: August 13th, 2011, 1:48 am
by shypike
You could be right, I'll check.
Changing that overnight might upset other users though because
current interfacing apps don't seem to bothered by this.
Wrong implementation or not, you're the first with this complaint.

Re: JSON API: Wrong string delimiter

Posted: August 13th, 2011, 2:54 am
by WhatSAB
Ok thanks, will have to "fix" the parser then or replace the response before parsing :)

Re: JSON API: Wrong string delimiter

Posted: August 13th, 2011, 8:00 am
by WhatSAB
One more thought after replacing lots of things in the api response (False -> false, True -> true, None -> null, ...).
If you want to make it valid JSON one day this site is really useful: http://jsonlint.com/

Re: JSON API: Wrong string delimiter

Posted: August 13th, 2011, 10:18 am
by shypike
Weird, I thought I'd done all those things already.

Re: JSON API: Wrong string delimiter

Posted: August 14th, 2011, 9:45 am
by shypike
I cannot see what your actual API call is, but I think you omitted the &output=json part.
What you describe only happens when you omit the output specifier.
In that case, you get "plain" ASCII (or rather Python's str() rendering), which is not json.