using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
public static void Test()
var incident_responce = GetJson();
TestSelectroots(incident_responce);
TestDynamic(incident_responce);
Console.WriteLine("\nInput JSON: ");
Console.WriteLine(incident_responce);
static void TestSelectroots(string incident_responce)
var root = JToken.Parse(incident_responce);
var value = (string)root.SelectToken("result.sys_id");
Console.WriteLine("{0} = \"{1}\"", "root.Selectroot(\"result.sys_id\")", value);
Assert.IsTrue(value == "7fb4e50edb8c0b007ea0f4e9bf9619ba");
static void TestDynamic(string incident_responce)
dynamic root = JToken.Parse(incident_responce);
var value = (string)root.result.sys_id;
Console.WriteLine("{0} = \"{1}\"", "dynamic root.result.sys_id", value);
Assert.IsTrue(value == "7fb4e50edb8c0b007ea0f4e9bf9619ba");
""number"": ""INC0012618"",
""link"": ""//XXX.service-now.com/api/now/v1/table/sys_user/38723e5ddb42f200deb8f6fcbf96196d"",
""value"": ""38723e5ddb42f200deb8f6fcbf96196d""
""sys_created_on"": ""2017-07-20 14:41:52"",
""link"": ""://XXX.service-now.com/api/now/v1/table/sys_user_group/global"",
""u_incident_summary"": """",
""link"": ""://xxx.service-now.com/api/now/v1/table/cmdb_ci_service/IT services"",
""value"": ""IT services""
""link"": ""://xxxx.service-now.com/api/now/v1/table/sys_user/71f5455d4f735e000d7f0ed11310c719"",
""value"": ""71f5455d4f735e000d7f0ed11310c719""
""link"": ""://xxx.service-now.com/api/now/v1/table/sys_user_group/9e158987dba27a007ea0f4e9bf961983"",
""value"": ""9e158987dba27a007ea0f4e9bf961983""
""sys_id"": ""7fb4e50edb8c0b007ea0f4e9bf9619ba"",
""u_outage_start_time"": """"
public class AssertionFailedException : System.Exception
public AssertionFailedException() : base() { }
public AssertionFailedException(string s) : base(s) { }
public static class Assert
public static void IsTrue(bool value)
throw new AssertionFailedException("failed");
public static void Main()
Console.WriteLine("Environment version: " + Environment.Version);
Console.WriteLine("Json.NET version: " + typeof(JsonSerializer).Assembly.FullName);