Funny you should ask about a JSON parser. I was just investigating whether or not the clientapi should have one, or wait until the framework gets one with the integration of Atlas into the .NET Framework.
I am leaning towards waiting since I have no desire to write that type of code, nor do I have the time to.
So what do I do in the meantime, since I need this as well. I am writing my own ToJSON method on my objects I need it. Eventually I probably will call a serialize method, but for now I am hand-coding each property. In my case I have a DNNToolBar object with properties, one of which is a Buttons collection, which contains a collection of DNNToolBarButtons.
DNNToolBar.vb
Friend Function ToJSON() As String
Dim oHash As Hashtable = New Hashtable
If Len(Me.CssClass) > 0 Then
oHash.Add("css", "'" & Me.CssClass & "'")
End If
If Me.MouseOutDelay <> 250 Then
oHash.Add("mod", Me.MouseOutDelay)
End If
If Len(Me.Visible) > 0 Then
oHash.Add("vis", CInt(Me.Visible))
End If
Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder
sb.Append("[")
For Each objBtn As DNNToolBarButton In Me.Buttons
If sb.Length > 1 Then sb.Append(",")
sb.Append(objBtn.ToJSON())
Next
sb.Append("]")
oHash.Add("btns", sb.ToString)
sb = New System.Text.StringBuilder
sb.Append("{")
For Each strKey As String In oHash.Keys
If sb.Length > 1 Then sb.Append(",")
sb.Append(strKey & ":" & CStr(oHash(strKey)))
Next
sb.Append("}")
Return sb.ToString
DNNToolBarButton.vb
Public Function ToJSON() As String
Dim oHash As Hashtable = New Hashtable
Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder
If Len(Me.CssClass) > 0 Then
oHash.Add("css", "'" & Me.CssClass & "'")
End If
If Len(Me.CssClassHover) > 0 Then
oHash.Add("cssh", "'" & Me.CssClassHover & "'")
End If
If Len(Me.ImageUrl) > 0 Then
oHash.Add("img", "'" & Me.ImageUrl & "'")
End If
If Len(Me.JSFunction) > 0 Then
oHash.Add("js", "'" & Me.JSFunction & "'")
End If
If Len(Me.Key) > 0 Then
oHash.Add("key", "'" & Me.Key & "'")
End If
If Len(Me.NavigateUrl) > 0 Then
oHash.Add("url", "'" & Me.NavigateUrl & "'")
End If
If Len(Me.Text) > 0 Then
oHash.Add("txt", "'" & Me.Text & "'")
End If
If Me.Visible = False Then
oHash.Add("vis", CInt(Me.Visible))
End If
sb.Append("{")
For Each strKey As String In oHash.Keys
If sb.Length > 1 Then sb.Append(",")
sb.Append(strKey & ":" & CStr(oHash(strKey)))
Next
sb.Append("}")
Return sb.ToString
End Function
On the Client I simply take the string value and do an eval
var oToolBar = eval(myJSON);
Then I can do things like oToolbar.css or oToolbar.btns[0].txt