Skip to content

Commit a155176

Browse files
committed
system.text.json: update github rest api
Update GitHub REST API-related code to use System.Text.Json rather than Json.NET for JSON deserialization.
1 parent 50c7edc commit a155176

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/shared/GitHub/GitHubRestApi.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
using System.Text.RegularExpressions;
99
using System.Threading.Tasks;
1010
using GitCredentialManager;
11-
using Newtonsoft.Json;
11+
using System.Text.Json;
12+
using System.Text.Json.Serialization;
1213

1314
namespace GitHub
1415
{
@@ -105,7 +106,7 @@ public async Task<GitHubUserInfo> GetUserInfoAsync(Uri targetUri, string accessT
105106

106107
string json = await response.Content.ReadAsStringAsync();
107108

108-
return JsonConvert.DeserializeObject<GitHubUserInfo>(json);
109+
return JsonSerializer.Deserialize<GitHubUserInfo>(json);
109110
}
110111
}
111112
}
@@ -124,7 +125,7 @@ public async Task<GitHubMetaInfo> GetMetaInfoAsync(Uri targetUri)
124125

125126
string json = await response.Content.ReadAsStringAsync();
126127

127-
return JsonConvert.DeserializeObject<GitHubMetaInfo>(json);
128+
return JsonSerializer.Deserialize<GitHubMetaInfo>(json);
128129
}
129130
}
130131

@@ -265,16 +266,16 @@ public void Dispose()
265266

266267
public class GitHubUserInfo
267268
{
268-
[JsonProperty("login")]
269+
[JsonPropertyName("login")]
269270
public string Login { get; set; }
270271
}
271272

272273
public class GitHubMetaInfo
273274
{
274-
[JsonProperty("installed_version")]
275+
[JsonPropertyName("installed_version")]
275276
public string InstalledVersion { get; set; }
276277

277-
[JsonProperty("verifiable_password_authentication")]
278+
[JsonPropertyName("verifiable_password_authentication")]
278279
public bool VerifiablePasswordAuthentication { get; set; }
279280
}
280281

0 commit comments

Comments
 (0)