I am developing a C # application that can manage SqueezeboxServer (SBS). Communication with SBS is done using JSON messages for http: // serverIP: 9000 / jsonrpc.js
Therefore, I send JSON messages through HTTPWepRequest and receive responses through HTTPWebResponse.
The answer I get is a JSON string. And here the problems begin ... In the meantime, I will convert the JSON message to an object using JavaScriptSerializer. It looks like this:
public static Object FromJSON(this string reply)
{
JavaScriptSerializer deSerializer = new JavaScriptSerializer();
return deSerializer.DeserializeObject(reply);
}
This code gives me an object that contains the data I request. The data I request can be very different. Sometimes the answer is one answer, but in other situations it can be several things.
Let's look at the two images that I included:
The first shows the object after it was returned by deSerializer. You can see that the object is a dictionary with 4 key-value pairs. The KVP I'm interested in is fourth. The key βresultβ is the one that contains the data I need. But this key has another Dictonary as its value. And this will continue until I get real data, namely the name of the album and its identifier.

In the second image, I want to get the value 0, which belongs to the key "_count". As you can see, this object is less complicated.

So, the essence of my question is how can I find a solution that can get the information I need, but works with different types of objects (like at different depths)?
Hope someone can send me in the right direction.
Thank!