public static object ParseQuotedPrimitive(string value) { if (string.IsNullOrEmpty(value)) { return(null); } #if NET40 Guid guidValue; if (Guid.TryParse(value, out guidValue)) { return(guidValue); } #endif if (value.StartsWith(DateTimeSerializer.EscapedWcfJsonPrefix) || value.StartsWith(DateTimeSerializer.WcfJsonPrefix)) { return(DateTimeSerializer.ParseWcfJsonDate(value)); } return(Serializer.UnescapeString(value)); }
public static object ParseQuotedPrimitive(string value) { if (string.IsNullOrEmpty(value)) { return(null); } #if NET40 Guid guidValue; if (Guid.TryParse(value, out guidValue)) { return(guidValue); } #endif if (value.StartsWith(DateTimeSerializer.EscapedWcfJsonPrefix, StringComparison.Ordinal) || value.StartsWith(DateTimeSerializer.WcfJsonPrefix, StringComparison.Ordinal)) { return(DateTimeSerializer.ParseWcfJsonDate(value)); } if (JsConfig.DateHandler == JsonDateHandler.ISO8601) { // check that we have UTC ISO8601 date: // YYYY-MM-DDThh:mm:ssZ // YYYY-MM-DDThh:mm:ss+02:00 // YYYY-MM-DDThh:mm:ss-02:00 if (value.Length > 14 && value[10] == 'T' && (value.EndsWithInvariant("Z") || value[value.Length - 6] == '+' || value[value.Length - 6] == '-')) { return(DateTimeSerializer.ParseShortestXsdDateTime(value)); } } return(Serializer.UnescapeString(value)); }