CSharp · Console
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
public class Program
{
public static void Main()
{
string json = @"
{
""profiles"": {
""1.7.10"": {
""name"": ""1.7.10"",
""lastVersionId"": ""1.7.10""
},
""foo.bar"": {
""name"": ""foo.bar"",
""lastVersionId"": ""x.y.z""
}
},
""selectedProfile"": ""1.7.10""
}";
RootObject root = JsonConvert.DeserializeObject<RootObject>(json);
foreach (var kvp in root.profiles)
{
Console.WriteLine("Name: " + kvp.Value.name);
Console.WriteLine("LastVersionId: " + kvp.Value.lastVersionId);
Console.WriteLine();
}
}
}
public class RootObject
{
public Dictionary<string, Profile> profiles { get; set; }
public string selectedProfile { get; set; }
}
public class Profile
{
public string name { get; set; }
public string lastVersionId { get; set; }
}