.NET Classes for XBMC
#1
Just out of interest, has anyone developed any classes (Video, Music in particular) for .NET?

I'm trying to understand how to manipulate the JSON responses but I'm having a hard time trying to decipher it. Having .NET classes may make it easier to understand for me (and perhaps others). I'm specifically writing in VB as my C++/C# skills are somewhat lacking.

Just out of curiosity...
Image
Reply
#2
Cheating with braindeadifed wrappers will sure keep you at a vb level.. also there is a search button and no new thoughts under the sun...
Reply
#3
(2012-07-24, 12:13)spiff Wrote: Cheating with braindeadifed wrappers will sure keep you at a vb level.. also there is a search button and no new thoughts under the sun...

Try doing a search in Google and get some decent, explanatory results... The results I've found are all aimed at C++/C# programmers and no matter how hard I try to convert the code (using logic) I'm stuck at getting a single "paramater" (for arguments sake, miovie runtime) from a query.

Let me explain what I'm trying to achieve in the simplest form to see if anyone can show what an idiot I am being and how easy it really is...

I get a response of {"id":"0","jsonrpc":"2.0","result":[{"playerid":1,"type":"video"}]}

How do I pick out just the "type" key pair without having to break down the response manually (via a function)?
Image
Reply
#4
If you are using VB.NET and you found some C# code you should just be able to use those classes in your VB.NET code. That's the whole advantage of the CLR.

There's no simple answer to your question. It depends on what library you use for JSON decoding. There are (at least) two (more or less outdated) C# based libraries somehwere in this forum which show how to interact with XBMC's JSON-RPC.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#5
(2012-07-24, 12:57)Montellese Wrote: If you are using VB.NET and you found some C# code you should just be able to use those classes in your VB.NET code. That's the whole advantage of the CLR.

There's no simple answer to your question. It depends on what library you use for JSON decoding. There are (at least) two (more or less outdated) C# based libraries somehwere in this forum which show how to interact with XBMC's JSON-RPC.

Thanks for the response. Currently I'm trying to use Newtonsoft.Json.Linq but I'm struggling how to decifer the code as all I seem to get is either a wrong result or an object not attached error. Hmm, I've not tried a search on "interact with XBMC's JSON-RPC" so maybe I'll try that one...
Image
Reply
#6
OK. I have come up with a solution which APPEARS to work without errors.

Code:
Public Function jsonParser(ByVal responseCode As String, ByVal responseRequired As String) As String
        Dim responseArgs() As String = Regex.Replace(responseCode, "[[\{}""]]*", "").Split(",")
        Dim responseCheck As String = Nothing
        Dim argumentCheck() As String = Nothing
        If (responseRequired IsNot Nothing) Then
            For Each argument As String In responseArgs
                If (argument.StartsWith("result") OrElse argument.StartsWith(responseRequired)) Then
                    argumentCheck = argument.Split(":")
                    For argCount = 0 To argumentCheck.Length - 1
                        responseCheck = argumentCheck(argCount).ToString()
                        If (responseCheck = responseRequired) Then
                            Return (argumentCheck(argCount + 1)).ToString()
                        End If
                    Next
                End If
            Next
        End If
        Return Nothing
    End Function

This is completely internal/self sufficient and doesn't use any special json imports/references.
Image
Reply

Logout Mark Read Team Forum Stats Members Help
.NET Classes for XBMC0