using System.Collections.Generic;
using Newtonsoft.Json.Linq;
public int Id { get; set; }
public string ServerName { get; set; }
public string RootDrive { get; set; }
public string Fqdn { get; set; }
public string Ip { get; set; }
public string Unc { get; set; }
public string Type { get; set; }
public string Domain { get; set; }
public string PoolStatus { get; set; }
public bool IsActive { get; set; }
public IEnumerable<String> Applications { get; set; }
public IEnumerable<String> GlobalDatabases { get; set; }
public IEnumerable<String> ClientDatabases { get; set; }
public IEnumerable<String> PhysicalDatabases { get; set; }
public IEnumerable<String> Products { get; set; }
public IEnumerable<String> Roles { get; set; }
public IEnumerable<Object> Drives { get; set; }
public static string jsonString = "[ { \"id\": 91, \"serverName\": \"server1\", \"fqdn\": \"server1.example.local\", \"ip\": \"10.10.10.1\", \"type\": \"Primary\", \"domain\": \"example.local\", \"isActive\": true, \"globalDatabases\": [ \"Auditing\", \"Reporting\", \"Logging\" ], \"clientDatabases\": [ \"client01\", \"client02\", \"client03\", \"client04\", \"client05\", \"client06\", \"client07\", \"client08\", \"client09\", \"client10\", \"client11\", \"client12\", \"client13\", \"client14\", \"client15\", \"client16\", \"client17\", \"client18\", \"client19\", \"client20\", \"client21\" ], \"products\": [ \"Example Product\" ], \"drives\": [ { \"type\": \"Data\", \"drives\": [ \"C:\\\\SQLDATA\" ] }, { \"type\": \"Log\", \"drives\": [ \"W:\\\\SQLLOGS\" ] } ] }, { \"id\": 96, \"serverName\": \"server2\", \"fqdn\": \"server2.example.local\", \"ip\": \"10.10.10.2\", \"type\": \"Reporting\", \"domain\": \"example.local\", \"isActive\": true, \"globalDatabases\": [ \"Reporting\" ], \"clientDatabases\": [ \"client01_Reporting\", \"client02_Reporting\", \"client05_Reporting\", \"client15_Reporting\", \"client17_Reporting\", \"client18_Reporting\" ], \"products\": [ \"Example Product\" ], \"drives\": [ { \"type\": \"Data\", \"drives\": [ \"D:\\\\data\" ] }, { \"type\": \"Log\", \"drives\": [ \"E:\\\\log\" ] } ] } ]";
public static void Main()
JSONtoObject(jsonString);
public static object JSONtoObject(string origString) {
var parsedJSONobject = JContainer.Parse(origString);
Console.WriteLine(parsedJSONobject.SelectToken("[0].id"));
Console.WriteLine(parsedJSONobject.SelectToken("[0]"));
var serverobj = parsedJSONobject.SelectToken("[0]").ToObject<Server>();
var queryresults = parsedJSONobject.SelectTokens("$.[*].id");
foreach (var aaa in queryresults) {