本文整理汇总了C#中SimpleJsonSerializer.Deserialize方法的典型用法代码示例。如果您正苦于以下问题:C# SimpleJsonSerializer.Deserialize方法的具体用法?C# SimpleJsonSerializer.Deserialize怎么用?C# SimpleJsonSerializer.Deserialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleJsonSerializer
的用法示例。
在下文中一共展示了SimpleJsonSerializer.Deserialize方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetShowcases
public async Task<List<Showcase>> GetShowcases()
{
var url = string.Format(ShowcaseUrl, string.Empty);
var data = await BlobCache.LocalMachine.DownloadUrl(url, absoluteExpiration: DateTimeOffset.Now.AddDays(1));
var serializer = new SimpleJsonSerializer();
return serializer.Deserialize<List<Showcase>>(Encoding.UTF8.GetString(data));
}
示例2: GetTrendingRepositories
public async Task<List<Octokit.Repository>> GetTrendingRepositories(string since, string language = null)
{
var query = "?since=" + since;
if (!string.IsNullOrEmpty(language))
query += string.Format("&language={0}", language);
var data = await BlobCache.LocalMachine.DownloadUrl(TrendingUrl + query, absoluteExpiration: DateTimeOffset.Now.AddHours(1));
var serializer = new SimpleJsonSerializer();
return serializer.Deserialize<List<Octokit.Repository>>(Encoding.UTF8.GetString(data));
}
示例3: CanBeDeserialized
public void CanBeDeserialized()
{
var serializer = new SimpleJsonSerializer();
var apiError = serializer.Deserialize<ApiError>(json);
Assert.Equal("Validation Failed", apiError.Message);
Assert.Equal(1, apiError.Errors.Count);
Assert.Equal("Issue", apiError.Errors[0].Resource);
Assert.Equal("title", apiError.Errors[0].Field);
Assert.Equal("missing_field", apiError.Errors[0].Code);
}
示例4: GetTrendingRepositories
public async Task<IList<GitHubSharp.Models.RepositoryModel>> GetTrendingRepositories(string since, string language = null)
{
var query = "?since=" + since;
if (!string.IsNullOrEmpty(language))
query += string.Format("&language={0}", language);
var client = new HttpClient();
var serializer = new SimpleJsonSerializer();
var msg = await client.GetAsync(TrendingUrl + query).ConfigureAwait(false);
var content = await msg.Content.ReadAsStringAsync().ConfigureAwait(false);
return serializer.Deserialize<List<GitHubSharp.Models.RepositoryModel>>(content);
}
示例5: CanBeDeserializedWithNullPrivateGistsDiskUsageAndCollaborators
public void CanBeDeserializedWithNullPrivateGistsDiskUsageAndCollaborators()
{
const string json = @"{
""login"": ""octocat"",
""id"": 1234,
""url"": ""https://api.github.com/orgs/octocat"",
""repos_url"": ""https://api.github.com/orgs/octocat/repos"",
""events_url"": ""https://api.github.com/orgs/octocat/events"",
""hooks_url"": ""https://api.github.com/orgs/octocat/hooks"",
""issues_url"": ""https://api.github.com/orgs/octocat/issues"",
""members_url"": ""https://api.github.com/orgs/octocat/members{/member}"",
""public_members_url"": ""https://api.github.com/orgs/octocat/public_members{/member}"",
""avatar_url"": ""https://avatars.githubusercontent.com/u/1234?v=3"",
""description"": ""Test org."",
""name"": ""Octocat"",
""company"": null,
""blog"": ""http://octocat.abc"",
""location"": """",
""email"": """",
""public_repos"": 13,
""public_gists"": 0,
""followers"": 0,
""following"": 0,
""html_url"": ""https://github.com/octocat"",
""created_at"": ""2012-09-11T21:54:25Z"",
""updated_at"": ""2016-08-02T05:44:12Z"",
""type"": ""Organization"",
""total_private_repos"": 1,
""owned_private_repos"": 1,
""private_gists"": null,
""disk_usage"": null,
""collaborators"": null,
""billing_email"": null,
""plan"": {
""name"": ""organization"",
""space"": 976562499,
""private_repos"": 9999,
""filled_seats"": 45,
""seats"": 45
}
}";
var serializer = new SimpleJsonSerializer();
var org = serializer.Deserialize<Organization>(json);
Assert.Equal("octocat", org.Login);
Assert.Equal(1234, org.Id);
}
示例6: CanBeDeserialized
public void CanBeDeserialized()
{
const string json = @"{
""total_count"": 40,
""incomplete_results"": false,
""items"": [
{
""id"": 3081286,
""name"": ""Tetris"",
""full_name"": ""dtrupenn/Tetris"",
""owner"": {
""login"": ""dtrupenn"",
""id"": 872147,
""avatar_url"": ""https://secure.gravatar.com/avatar/e7956084e75f239de85d3a31bc172ace?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png"",
""gravatar_id"": """",
""url"": ""https://api.github.com/users/dtrupenn"",
""received_events_url"": ""https://api.github.com/users/dtrupenn/received_events"",
""type"": ""User""
},
""private"": false,
""html_url"": ""https://github.com/dtrupenn/Tetris"",
""description"": ""A C implementation of Tetris using Pennsim through LC4"",
""fork"": false,
""url"": ""https://api.github.com/repos/dtrupenn/Tetris"",
""created_at"": ""2012-01-01T00:31:50Z"",
""updated_at"": ""2013-01-05T17:58:47Z"",
""pushed_at"": ""2012-01-01T00:37:02Z"",
""homepage"": """",
""size"": 524,
""stargazers_count"": 1,
""watchers_count"": 1,
""language"": ""Assembly"",
""forks_count"": 0,
""open_issues_count"": 0,
""master_branch"": ""master"",
""default_branch"": ""master"",
""score"": 10.309712
}
]
}";
var serializer = new SimpleJsonSerializer();
var results = serializer.Deserialize<SearchRepositoryResult>(json);
Assert.Equal(40, results.TotalCount);
Assert.False(results.IncompleteResults);
}
示例7: CanBeDeserialized
public void CanBeDeserialized()
{
const string json = @"{
""message"": ""Validation Failed"",
""errors"": [
{
""resource"": ""Issue"",
""field"": ""title"",
""code"": ""missing_field""
}
]
}";
var serializer = new SimpleJsonSerializer();
var apiError = serializer.Deserialize<ApiError>(json);
Assert.Equal("Validation Failed", apiError.Message);
Assert.Equal(1, apiError.Errors.Count);
Assert.Equal("Issue", apiError.Errors[0].Resource);
Assert.Equal("title", apiError.Errors[0].Field);
Assert.Equal("missing_field", apiError.Errors[0].Code);
}
示例8: CanBeDeserialized
public void CanBeDeserialized()
{
const string json = @"{
""id"": 1,
""url"": ""https://api.github.com/repos/octocat/Hello-World/issues/1347"",
""html_url"": ""https://github.com/octocat/Hello-World/issues/1347"",
""number"": 1347,
""state"": ""open"",
""title"": ""Found a bug"",
""body"": ""I'm having a problem with this."",
""user"": {
""login"": ""octocat"",
""id"": 1,
""avatar_url"": ""https://github.com/images/error/octocat_happy.gif"",
""gravatar_id"": """",
""url"": ""https://api.github.com/users/octocat"",
""html_url"": ""https://github.com/octocat"",
""followers_url"": ""https://api.github.com/users/octocat/followers"",
""following_url"": ""https://api.github.com/users/octocat/following{/other_user}"",
""gists_url"": ""https://api.github.com/users/octocat/gists{/gist_id}"",
""starred_url"": ""https://api.github.com/users/octocat/starred{/owner}{/repo}"",
""subscriptions_url"": ""https://api.github.com/users/octocat/subscriptions"",
""organizations_url"": ""https://api.github.com/users/octocat/orgs"",
""repos_url"": ""https://api.github.com/users/octocat/repos"",
""events_url"": ""https://api.github.com/users/octocat/events{/privacy}"",
""received_events_url"": ""https://api.github.com/users/octocat/received_events"",
""type"": ""User"",
""site_admin"": false
},
""labels"": [
{
""url"": ""https://api.github.com/repos/octocat/Hello-World/labels/bug"",
""name"": ""bug"",
""color"": ""f29513""
}
],
""assignee"": {
""login"": ""octocat"",
""id"": 1,
""avatar_url"": ""https://github.com/images/error/octocat_happy.gif"",
""gravatar_id"": """",
""url"": ""https://api.github.com/users/octocat"",
""html_url"": ""https://github.com/octocat"",
""followers_url"": ""https://api.github.com/users/octocat/followers"",
""following_url"": ""https://api.github.com/users/octocat/following{/other_user}"",
""gists_url"": ""https://api.github.com/users/octocat/gists{/gist_id}"",
""starred_url"": ""https://api.github.com/users/octocat/starred{/owner}{/repo}"",
""subscriptions_url"": ""https://api.github.com/users/octocat/subscriptions"",
""organizations_url"": ""https://api.github.com/users/octocat/orgs"",
""repos_url"": ""https://api.github.com/users/octocat/repos"",
""events_url"": ""https://api.github.com/users/octocat/events{/privacy}"",
""received_events_url"": ""https://api.github.com/users/octocat/received_events"",
""type"": ""User"",
""site_admin"": false
},
""milestone"": {
""url"": ""https://api.github.com/repos/octocat/Hello-World/milestones/1"",
""number"": 1,
""state"": ""open"",
""title"": ""v1.0"",
""description"": """",
""creator"": {
""login"": ""octocat"",
""id"": 1,
""avatar_url"": ""https://github.com/images/error/octocat_happy.gif"",
""gravatar_id"": """",
""url"": ""https://api.github.com/users/octocat"",
""html_url"": ""https://github.com/octocat"",
""followers_url"": ""https://api.github.com/users/octocat/followers"",
""following_url"": ""https://api.github.com/users/octocat/following{/other_user}"",
""gists_url"": ""https://api.github.com/users/octocat/gists{/gist_id}"",
""starred_url"": ""https://api.github.com/users/octocat/starred{/owner}{/repo}"",
""subscriptions_url"": ""https://api.github.com/users/octocat/subscriptions"",
""organizations_url"": ""https://api.github.com/users/octocat/orgs"",
""repos_url"": ""https://api.github.com/users/octocat/repos"",
""events_url"": ""https://api.github.com/users/octocat/events{/privacy}"",
""received_events_url"": ""https://api.github.com/users/octocat/received_events"",
""type"": ""User"",
""site_admin"": false
},
""open_issues"": 4,
""closed_issues"": 8,
""created_at"": ""2011-04-10T20:09:31Z"",
""updated_at"": ""2014-03-03T18:58:10Z"",
""closed_at"": ""2013-02-12T13:22:01Z"",
""due_on"": null
},
""comments"": 0,
""pull_request"": {
""url"": ""https://api.github.com/repos/octocat/Hello-World/pulls/1347"",
""html_url"": ""https://github.com/octocat/Hello-World/pull/1347"",
""diff_url"": ""https://github.com/octocat/Hello-World/pull/1347.diff"",
""patch_url"": ""https://github.com/octocat/Hello-World/pull/1347.patch""
},
""closed_at"": null,
""created_at"": ""2011-04-22T13:33:48Z"",
""updated_at"": ""2011-04-22T13:33:48Z"",
""closed_by"": {
""login"": ""octocat"",
""id"": 1,
//.........这里部分代码省略.........
示例9: CreateIssue
static Issue CreateIssue(int issueNumber)
{
var serializer = new SimpleJsonSerializer();
return serializer.Deserialize<Issue>(@"{""number"": """ + issueNumber + @"""}");
}
示例10: CanDeserializeAnUnsubscribedIssueEvent
public void CanDeserializeAnUnsubscribedIssueEvent()
{
const string json = @"{
""id"": 42,
""url"": ""https://api.github.com/repos/octocat/Hello-World/issues/events/42"",
""actor"": {
""login"": ""octocat"",
""id"": 1060,
""avatar_url"": ""https://avatars.githubusercontent.com/u/1?v=3"",
""gravatar_id"": """",
""url"": ""https://api.github.com/users/octocat"",
""html_url"": ""https://github.com/octocat"",
""followers_url"": ""https://api.github.com/users/octocat/followers"",
""following_url"": ""https://api.github.com/users/octocat/following{/other_user}"",
""gists_url"": ""https://api.github.com/users/octocat/gists{/gist_id}"",
""starred_url"": ""https://api.github.com/users/octocat/starred{/owner}{/repo}"",
""subscriptions_url"": ""https://api.github.com/users/octocat/subscriptions"",
""organizations_url"": ""https://api.github.com/users/octocat/orgs"",
""repos_url"": ""https://api.github.com/users/octocat/repos"",
""events_url"": ""https://api.github.com/users/octocat/events{/privacy}"",
""received_events_url"": ""https://api.github.com/users/octocat/received_events"",
""type"": ""User"",
""site_admin"": false
},
""event"": ""unsubscribed"",
""commit_id"": null,
""created_at"": ""2014-07-16T15:41:42Z"",
""issue"": {
""url"": ""https://api.github.com/repos/octocat/Hello-World/issues/1205"",
""labels_url"": ""https://api.github.com/repos/octocat/Hello-World/issues/1205/labels{/name}"",
""comments_url"": ""https://api.github.com/repos/octocat/Hello-World/issues/1205/comments"",
""events_url"": ""https://api.github.com/repos/octocat/Hello-World/issues/1205/events"",
""html_url"": ""https://github.com/octocat/Hello-World/issues/1205"",
""id"": 37995243,
""number"": 1205,
""title"": ""settings icon should not be visible on sidebar if you are not a collaborator for public repos (and should not be accessible at /settings)"",
""user"": {
""login"": ""ashumz"",
""id"": 100216,
""avatar_url"": ""https://avatars.githubusercontent.com/u/6?v=3"",
""gravatar_id"": """",
""url"": ""https://api.github.com/users/octocat"",
""html_url"": ""https://github.com/octocat"",
""followers_url"": ""https://api.github.com/users/octocat/followers"",
""following_url"": ""https://api.github.com/users/octocat/following{/other_user}"",
""gists_url"": ""https://api.github.com/users/octocat/gists{/gist_id}"",
""starred_url"": ""https://api.github.com/users/octocat/starred{/owner}{/repo}"",
""subscriptions_url"": ""https://api.github.com/users/octocat/subscriptions"",
""organizations_url"": ""https://api.github.com/users/octocat/orgs"",
""repos_url"": ""https://api.github.com/users/octocat/repos"",
""events_url"": ""https://api.github.com/users/octocat/events{/privacy}"",
""received_events_url"": ""https://api.github.com/users/octocat/received_events"",
""type"": ""User"",
""site_admin"": false
},
""labels"": [
{
""url"": ""https://api.github.com/repos/octocat/Hello-World/labels/bug"",
""name"": ""bug"",
""color"": ""fc2929""
},
{
""url"": ""https://api.github.com/repos/octocat/Hello-World/labels/waffle:ready"",
""name"": ""octocat:ready"",
""color"": ""00c5fe""
}
],
""state"": ""closed"",
""locked"": false,
""assignee"": null,
""milestone"": null,
""comments"": 0,
""created_at"": ""2014-07-16T15:39:21Z"",
""updated_at"": ""2014-07-16T22:16:37Z"",
""closed_at"": ""2014-07-16T22:16:37Z"",
""body"": ""body content""
}
}";
var serializer = new SimpleJsonSerializer();
var issueEvent = serializer.Deserialize<IssueEvent>(json);
Assert.NotNull(issueEvent);
Assert.Equal(EventInfoState.Unsubscribed, issueEvent.Event);
}
示例11: GetLanguages
public async Task<List<Language>> GetLanguages()
{
var trendingData = await BlobCache.LocalMachine.DownloadUrl(LanguagesUrl, absoluteExpiration: DateTimeOffset.Now.AddDays(1));
var serializer = new SimpleJsonSerializer();
return serializer.Deserialize<List<Language>>(Encoding.UTF8.GetString(trendingData));
}
示例12: CanBeDeserialized
public void CanBeDeserialized()
{
const string json = @"{
""url"": ""https://api.github.com/gists/0eb90eaf2402c59aee09"",
""forks_url"": ""https://api.github.com/gists/4ce20519be87ca0acb15/forks"",
""commits_url"": ""https://api.github.com/gists/0b764844068508e7b5a6/commits"",
""id"": ""1"",
""description"": ""description of gist"",
""public"": true,
""owner"": {
""login"": ""octocat"",
""id"": 1,
""avatar_url"": ""https://github.com/images/error/octocat_happy.gif"",
""gravatar_id"": """",
""url"": ""https://api.github.com/users/octocat"",
""html_url"": ""https://github.com/octocat"",
""followers_url"": ""https://api.github.com/users/octocat/followers"",
""following_url"": ""https://api.github.com/users/octocat/following{/other_user}"",
""gists_url"": ""https://api.github.com/users/octocat/gists{/gist_id}"",
""starred_url"": ""https://api.github.com/users/octocat/starred{/owner}{/repo}"",
""subscriptions_url"": ""https://api.github.com/users/octocat/subscriptions"",
""organizations_url"": ""https://api.github.com/users/octocat/orgs"",
""repos_url"": ""https://api.github.com/users/octocat/repos"",
""events_url"": ""https://api.github.com/users/octocat/events{/privacy}"",
""received_events_url"": ""https://api.github.com/users/octocat/received_events"",
""type"": ""User"",
""site_admin"": false
},
""user"": null,
""files"": {
""ring.erl"": {
""size"": 932,
""raw_url"": ""https://gist.githubusercontent.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl"",
""type"": ""text/plain"",
""language"": ""Erlang"",
""truncated"": false,
""content"": ""contents of gist""
}
},
""comments"": 0,
""comments_url"": ""https://api.github.com/gists/d2046eed1277da6549db/comments/"",
""html_url"": ""https://gist.github.com/1"",
""git_pull_url"": ""https://gist.github.com/1.git"",
""git_push_url"": ""https://gist.github.com/1.git"",
""created_at"": ""2010-04-14T02:15:15Z"",
""updated_at"": ""2011-06-20T11:34:15Z"",
""forks"": [
{
""user"": {
""login"": ""octocat"",
""id"": 1,
""avatar_url"": ""https://github.com/images/error/octocat_happy.gif"",
""gravatar_id"": """",
""url"": ""https://api.github.com/users/octocat"",
""html_url"": ""https://github.com/octocat"",
""followers_url"": ""https://api.github.com/users/octocat/followers"",
""following_url"": ""https://api.github.com/users/octocat/following{/other_user}"",
""gists_url"": ""https://api.github.com/users/octocat/gists{/gist_id}"",
""starred_url"": ""https://api.github.com/users/octocat/starred{/owner}{/repo}"",
""subscriptions_url"": ""https://api.github.com/users/octocat/subscriptions"",
""organizations_url"": ""https://api.github.com/users/octocat/orgs"",
""repos_url"": ""https://api.github.com/users/octocat/repos"",
""events_url"": ""https://api.github.com/users/octocat/events{/privacy}"",
""received_events_url"": ""https://api.github.com/users/octocat/received_events"",
""type"": ""User"",
""site_admin"": false
},
""url"": ""https://api.github.com/gists/bb67e0c133b671e06f9f"",
""id"": 1,
""created_at"": ""2011-04-14T16:00:49Z"",
""updated_at"": ""2011-04-14T16:00:49Z""
}
],
""history"": [
{
""url"": ""https://api.github.com/gists/3124ac0e05b9d93f7321"",
""version"": ""57a7f021a713b1c5a6a199b54cc514735d2d462f"",
""user"": {
""login"": ""octocat"",
""id"": 1,
""avatar_url"": ""https://github.com/images/error/octocat_happy.gif"",
""gravatar_id"": """",
""url"": ""https://api.github.com/users/octocat"",
""html_url"": ""https://github.com/octocat"",
""followers_url"": ""https://api.github.com/users/octocat/followers"",
""following_url"": ""https://api.github.com/users/octocat/following{/other_user}"",
""gists_url"": ""https://api.github.com/users/octocat/gists{/gist_id}"",
""starred_url"": ""https://api.github.com/users/octocat/starred{/owner}{/repo}"",
""subscriptions_url"": ""https://api.github.com/users/octocat/subscriptions"",
""organizations_url"": ""https://api.github.com/users/octocat/orgs"",
""repos_url"": ""https://api.github.com/users/octocat/repos"",
""events_url"": ""https://api.github.com/users/octocat/events{/privacy}"",
""received_events_url"": ""https://api.github.com/users/octocat/received_events"",
""type"": ""User"",
""site_admin"": false
},
""change_status"": {
""deletions"": 0,
""additions"": 180,
""total"": 180
//.........这里部分代码省略.........
示例13: DeserializesOAuthScopeFormat
public async Task DeserializesOAuthScopeFormat()
{
var responseText =
"{\"access_token\":\"token-goes-here\",\"token_type\":\"bearer\",\"scope\":\"notifications,user,user:email\"}";
var strategy = new SimpleJsonSerializer();
var token = strategy.Deserialize<OauthToken>(responseText);
Assert.Equal(token.AccessToken, "token-goes-here");
Assert.Equal(token.TokenType, "bearer");
Assert.True(token.Scope.Contains("notifications"));
Assert.True(token.Scope.Contains("user:email"));
}