JSON API: Wrong string delimiter

Report & discuss bugs found in SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
WhatSAB
Newbie
Newbie
Posts: 3
Joined: August 12th, 2011, 6:35 pm

JSON API: Wrong string delimiter

Post 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.
User avatar
shypike
Administrator
Administrator
Posts: 19773
Joined: January 18th, 2008, 12:49 pm

Re: JSON API: Wrong string delimiter

Post 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.
WhatSAB
Newbie
Newbie
Posts: 3
Joined: August 12th, 2011, 6:35 pm

Re: JSON API: Wrong string delimiter

Post by WhatSAB »

Ok thanks, will have to "fix" the parser then or replace the response before parsing :)
WhatSAB
Newbie
Newbie
Posts: 3
Joined: August 12th, 2011, 6:35 pm

Re: JSON API: Wrong string delimiter

Post 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/
User avatar
shypike
Administrator
Administrator
Posts: 19773
Joined: January 18th, 2008, 12:49 pm

Re: JSON API: Wrong string delimiter

Post by shypike »

Weird, I thought I'd done all those things already.
User avatar
shypike
Administrator
Administrator
Posts: 19773
Joined: January 18th, 2008, 12:49 pm

Re: JSON API: Wrong string delimiter

Post 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.
Post Reply