Iterate json objects

CSharp · Console

/Program.cs

using System;
using System.Collections.Generic;
using Newtonsoft.Json;
		
public class Foo
{
	public string name;
	public Dictionary<string, object> clients;
}

public class Program
{
	public static void Main()
	{
		var input = @"{""name"":""test"",""clients"": {""client1"": {""id"": ""1"", ""count"": ""41""},""client2"": {""name"": ""testName""},""client3"": {""CustomerID"": ""a1"", ""internalID"": ""testID""}}}";
		var foo = JsonConvert.DeserializeObject<Foo>(input);
		foreach (var item in foo.clients)
		{
			Console.WriteLine(item.Key);
		}
	}
}
;