SABnzbd API Issue Re: slots:""
Posted: September 22nd, 2010, 1:07 pm
I've been playing with google's gson (version 1.5) library, and it works wonders for parsing the JSON output (SABnzbd version 0.5.4), however I have come across a bit of an issue with the way "slots" are reported.
When there are no slots in use (noofslots: 0) slots are reported with:
"slots":""
Which implies to the library that it is a string not an array.
When there are slots in use it is reported as:
"slots":[{"status":"Queued","index":0,"eta":"unknown"......
If there are no values in the array, it should report
"slots":[]
As a result, the library throws
java.lang.ClassCastException: com.google.gson.JsonPrimitive cannot be cast to com.google.gson.JsonArray
I have been using a string replace before putting it through the GSON parser to get around the issue.
IE
string.replace("slots\":\"\"", "slots\":[]");
Maybe something to be fixed in the future, I couldn't find this issue in the forums, sorry if it's a double post.
When there are no slots in use (noofslots: 0) slots are reported with:
"slots":""
Which implies to the library that it is a string not an array.
When there are slots in use it is reported as:
"slots":[{"status":"Queued","index":0,"eta":"unknown"......
If there are no values in the array, it should report
"slots":[]
As a result, the library throws
java.lang.ClassCastException: com.google.gson.JsonPrimitive cannot be cast to com.google.gson.JsonArray
I have been using a string replace before putting it through the GSON parser to get around the issue.
IE
string.replace("slots\":\"\"", "slots\":[]");
Maybe something to be fixed in the future, I couldn't find this issue in the forums, sorry if it's a double post.