Search code examples
javajsonxbmc

How can I access the XBMC JSON interface via Java?


I've been searching for hours and I can't find the basics I need. :(

I'm starting small, right now I just want to get this Java program to contact the JSON interface for XBMC and retrieve a list of Music on it.

Can anyone please point me in the right direction? I'd be very grateful. Thank you :)

EDIT: I am also confused as to the terminology of JSON, so go easy please. I think the correct phrase is "I am trying to retrieve a JSON object from the server, and then post one back"?


Solution

  • So you'll need to do a few things. 1. Enable the JSON RPC on your XBMC server. 2. Get a JSON library to use with Java. Json-simple is a very minimal one. 3. Connect to the XBMC using either (a) http or (b) direct TCP socket connection. (a) lookup how to use java.net.URLConnection and java.net.HttpURLConnection (b) lookup how to use java.net.Socket [use the Socket(InetAddress address, int port) constructor where address & port is of the server]

    Good luck, David.