CSharp · Console
using System;
using Newtonsoft.Json;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
var json = "{\r\n \"sampleClass\":{ \"name\":\"Name\"} , \"sampleOtherClass\":{ \"name\":\"OtherName\"} ,\r\n \"X\": \"Jan\"\r\n}";
var result =JsonConvert.DeserializeObject<Test>(json);
foreach(var item in result.Y)
{
Console.WriteLine("key: " + item.Key);
Console.WriteLine("value: " + item.Value);
Console.WriteLine("type: " + item.Value.GetType());
Console.WriteLine("\n");
}
}
}
public class Test
{
public string X { get; set; }
[JsonExtensionData]
public Dictionary<string, object> Y { get; set; }
}
public class ClassName {
public string Name { get;set; }
}
public class SampleOtherClass {
public string Name { get;set; }
}