Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 62aa7c1

Browse files
committed
Add support for serializing UriString to json as a simple string
1 parent 042c21a commit 62aa7c1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/GitHub.Api/Helpers/SimpleJson.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,8 @@ public virtual object DeserializeObject(object value, Type type)
13741374
return DateTimeOffset.ParseExact(str, Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal);
13751375
if (type == typeof(Guid) || (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(Guid)))
13761376
return new Guid(str);
1377+
if (type == typeof(UriString) || (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(UriString)))
1378+
return new UriString(str);
13771379
if (type == typeof(Uri))
13781380
{
13791381
bool isValid = Uri.IsWellFormedUriString(str, UriKind.RelativeOrAbsolute);
@@ -1499,7 +1501,7 @@ protected virtual object SerializeEnum(Enum p)
14991501
protected virtual bool TrySerializeKnownTypes(object input, out object output)
15001502
{
15011503
bool returnValue = true;
1502-
if (input is NPath)
1504+
if (input is NPath || input is UriString)
15031505
output = input.ToString();
15041506
else if (input is DateTime)
15051507
output = ((DateTime)input).ToUniversalTime().ToString(Iso8601Format[0], CultureInfo.InvariantCulture);

0 commit comments

Comments
 (0)