CSharp · Console
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
public class Program
{
public static void Main()
{
string json = @"
{
""KnownPropName"": [
{
""DynamicPropName"": [
{
""KnownProp1"": ""value 1"",
""KnownProp2"": ""value 2""
},
{
""KnownProp1"": ""value 3"",
""KnownProp2"": ""value 4""
}
]
}
]
}";
var resp = JsonConvert.DeserializeObject<TestResponse>(json);
foreach (var dict in resp.KnownPropName)
{
foreach (var kvp in dict)
{
Console.WriteLine(kvp.Key);
foreach (var item in kvp.Value)
{
Console.WriteLine("KnownProp1: " + item.KnownProp1);
Console.WriteLine("KnownProp2: " + item.KnownProp2);
}
}
}
}
private class TestResponse
{
public Dictionary<string, TestInner[]>[] KnownPropName { get; set; }
}
private class TestInner
{
public string KnownProp1 { get; set; }
public string KnownProp2 { get; set; }
}
}