How to parse a TimeSpan value in Newtonsoft JSON
问题 I'd like parse JSON string and use the token.Type property to detect values of type JTokenType.TimeSpan . I can't work out how to express the TimeSpan in my input string, everything seems to be interpreted as JTokenType.String. var timeSpanString = TimeSpan.FromHours(1).ToString(); testString = string.Format(@"{{""Value"": ""{0}"" }}", timeSpanString); var statObject = JObject.Parse(testString); JToken token = statObject["Value"]; var tokenValue = token.ToString(); var tokenType = token.Type;