I am trying to get the array directly from the JSON "data" item into an array variable:
string jsonString = "{\"data\":[
{\"name\":false,\"number\":true},
{\"name\":false,\"number\":false},
{\"name\":true,\"number\":false}
]}";
var serializer = new JavaScriptSerializer();
serializer.RegisterConverters(new[] { new DynamicJsonConverter() });
dynamic jsonObject = serializer.Deserialize(jsonString, typeof(object));
Array jsonArray = jsonObject.data;
// Here error says:
//Cannot implicitly convert type 'System.Collections.Generic.List<object>' to 'System.Array'
dynamic lastJsonArrayData = jsonArray[jsonArray.Length - 1];
// this is where the error occurs, it says:
//Cannot apply indexing with [] to an expression of type 'Array'
and last thing that I need to do is to convert lastJsonArrayData
back to dynamic object but I dont know how.. And I need the last two steps to be performed separately as it stated, it means first to get the array then get the object!!
I am a total newbie in C#
EDIT: The real JSON structure is actually more like this:
string jsonString = "{\"firstlevel\":{\"secondlevel\":{\"data\":[
{\"name\":false,\"number\":true},
{\"name\":false,\"number\":false},
{\"name\":true,\"number\":false}
]}}}";