CSharp · Console
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
public class Program
{
public static void Main()
{
string json = @"
{
""Documents"": {
""c97bba6f-c8ab-4453-91f8-f663f478910c"": {
""id"": ""c97bba6f-c8ab-4453-91f8-f663f478910c"",
""name"": ""name"",
""sys"": {
""c67bfa6f-c8ab-4453-91f8-f663f478910c"": {
""id"": ""c97bba6f-c8ab-4453-91f8-f663f478910c"",
""name"": ""sys name""
},
""a67bfa6f-c8ab-4453-91f8-f663f478910c"": {
""id"": "" a67bfa6f-c8ab-4453-91f8-f663f478910c"",
""name"": ""sys name""
}
}
},
""f97bba6f-c8ab-4453-91f8-f663f478910c"": {
""id"": ""c97bba6f-c8ab-4453-91f8-f663f478910c"",
""name"": ""OZL - B - MECH - AC - Fan Coil Units"",
""sys"": {}
}
}
}";
var root = JsonConvert.DeserializeObject<RootObject>(json);
foreach (var doc in root.Documents.Values)
{
Console.WriteLine("Id: " + doc.Id);
Console.WriteLine("Name: " + doc.Name);
Console.WriteLine("Sys:");
foreach (var sys in doc.Sys.Values)
{
Console.WriteLine(" Id: " + sys.Id);
Console.WriteLine(" Name: " + sys.Name);
}
Console.WriteLine();
}
}
}
public class RootObject
{
public Dictionary<Guid, Document> Documents { get; set; }
}
public class Document
{
public Guid Id { get; set; }
public string Name { get; set; }
public Dictionary<Guid, Sys> Sys { get; set; }
}
public class Sys
{
public Guid Id { get; set; }
public string Name { get; set; }
}