using Newtonsoft.Json.Linq;
public static JObject testObj = JObject.Parse(@"{
'SupportAutomaticPlacement': true,
'hostGroup': 'test/HostGroup'
public static void Main()
var first = (string)testObj?.SelectToken("$.SupportAutomaticPlacement");
var sec = (string)testObj.SelectToken("$.host");
Console.WriteLine(first);
Console.WriteLine(helperMethod(testObj));
public static string helperMethod(JObject testObj)
if(!string.IsNullOrWhiteSpace((string)testObj.SelectToken("$.host")))
return (string)testObj.SelectToken("$.host");
else if(!string.IsNullOrWhiteSpace((string)testObj.SelectToken("$.hostGroup")))
return (string)testObj.SelectToken("$.hostGroup");