2012-01-28, 12:17
I'm having a problem parsing the json result from XBMC using javascript/jquery.
I use the following code to get a list of movies from my xbmc media library:
At the moment I only want to put the json result in a <div> with the id: log.
What I get as a result in the log div is this:
{"error":{"code":-32700,"message":"Parse error."},"id":0,"jsonrpc":"2.0"}
When I send the data: { "jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { }, "id": 1 } to XBMC using the Simple REST client for Google Chrome I get a response from XBMC with a json encoded list of all the movies in my library.
According to Wikipedia error 32700 indicates that invalid Json is returned. However the result I get in the REST client looks valid to me.
The result I get using the REST client is:
Headers:
Data (snippet):
I'm stuck on what's causing the parse error. Is it the response from XBMC or am I sending the wrong data to XBMC? I hope some of you are able to point me in the right direction.
I use the following code to get a list of movies from my xbmc media library:
Code:
$.post('http://192.168.1.143:8080/jsonrpc', { "jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { }, "id": 1 },
function(data){
var movies = JSON.stringify(data);
$("#log").append("Data: <br />" + movies)
}, "json");
What I get as a result in the log div is this:
{"error":{"code":-32700,"message":"Parse error."},"id":0,"jsonrpc":"2.0"}
When I send the data: { "jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { }, "id": 1 } to XBMC using the Simple REST client for Google Chrome I get a response from XBMC with a json encoded list of all the movies in my library.
According to Wikipedia error 32700 indicates that invalid Json is returned. However the result I get in the REST client looks valid to me.
The result I get using the REST client is:
Headers:
Code:
Date: Sat, 28 Jan 2012 09:37:55 GMT
Content-Length: 29047
Content-Type: application/json
Code:
{
"id" : 1,
"jsonrpc" : "2.0",
"result" : {
"end" : 105,
"movies" : [
{
"fanart" : "special://masterprofile/Thumbnails/Video/Fanart/ffffffff.tbn",
"file" : "videodb://1/7/4/",
"label" : "James Bond Collection"
},
{
"fanart" : "special://masterprofile/Thumbnails/Video/Fanart/ffffffff.tbn",
"file" : "videodb://1/7/5/",
"label" : "Pirates of the Caribbean Collection"
},
{
"fanart" : "special://masterprofile/Thumbnails/Video/Fanart/ffffffff.tbn",
"file" : "videodb://1/7/6/",
"label" : "BBC Earth Yellowstone"
},
{
"fanart" : "special://masterprofile/Thumbnails/Video/Fanart/1df148d9.tbn",
"file" : "//desktop/films/Bride Wars [2009]/VIDEO_TS/VIDEO_TS.IFO",
"label" : "Bride Wars",
"movieid" : 1,
"thumbnail" : "special://masterprofile/Thumbnails/Video/1/1df148d9.tbn"
},
I'm stuck on what's causing the parse error. Is it the response from XBMC or am I sending the wrong data to XBMC? I hope some of you are able to point me in the right direction.