本文整理汇总了C#中JsonDeserializer类的典型用法代码示例。如果您正苦于以下问题:C# JsonDeserializer类的具体用法?C# JsonDeserializer怎么用?C# JsonDeserializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsonDeserializer类属于命名空间,在下文中一共展示了JsonDeserializer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetToken_Click
private void GetToken_Click(object sender, RoutedEventArgs e)
{
var client = new RestClient("https://api.home.nest.com/oauth2/access_token");
var request = new RestRequest(Method.POST);
request.AddParameter("client_id", TextNestClientId.Text);
request.AddParameter("code", TextNestPin.Text);
request.AddParameter("client_secret", PwNestSecret.Password);
request.AddParameter("grant_type", "authorization_code");
var response = client.Execute(request);
JsonDeserializer deserializer = new JsonDeserializer();
var json = deserializer.Deserialize<Dictionary<string, string>>(response);
if (json.ContainsKey("access_token"))
{
TextNestAccessToken.Text = json["access_token"];
return;
}
if (json.ContainsKey("message"))
{
TextNestAccessToken.Text = json["message"];
return;
}
if (json.ContainsKey("error_description"))
{
TextNestAccessToken.Text = json["error_description"];
return;
}
}
开发者ID:pacificIT,项目名称:FirebaseSharp,代码行数:32,代码来源:MainWindow.xaml.cs
示例2: Setup
public void Setup()
{
string url = ConfigurationManager.AppSettings["url"];
string clientKey = ConfigurationManager.AppSettings["client-key"];
string clientSecret = ConfigurationManager.AppSettings["client-secret"];
responsePath = ConfigurationManager.AppSettings["response-path"];
Assert.IsNotNullOrEmpty(clientKey);
Assert.IsNotNullOrEmpty(clientSecret);
Assert.IsNotNullOrEmpty(url);
// ReSharper disable UnusedVariable
//##BEGIN EXAMPLE accessingapi##
var api = new Api(url, clientKey, clientSecret);
var tokenResponse = api.Authenticate();
var rootLinks = api.Root;
//##END EXAMPLE##
// ReSharper restore UnusedVariable
responses = ResponseReader.readResponses(responsePath);
deserializer = new JsonDeserializer();
TestUtils.Deserializer = deserializer;
}
开发者ID:nfleet,项目名称:.net-sdk,代码行数:25,代码来源:ApiTests.cs
示例3: HitboxOnlineState
private static bool HitboxOnlineState(string sStream)
{
var req = new RestRequest("/media/live/" + sStream, Method.GET);
IRestClientProvider _restClientProvider = new RestClientProvider(new RestClient("http://api.hitbox.tv"));
var response = _restClientProvider.Execute(req);
try
{
var des = new JsonDeserializer();
var data = des.Deserialize<HitboxRootObject>(response);
foreach (var item in data.livestream)
{
if(item.media_user_name.ToLower() == sStream.ToLower())
{
if(item.media_is_live == "1")
{
return true;
}
}
}
return false;
}
catch (Exception)
{
return false;
}
}
开发者ID:Kolpa,项目名称:DeathmicChatbot,代码行数:28,代码来源:Stream+Static+Functions.cs
示例4: OnContentReceived
private void OnContentReceived(string content) {
JsonDeserializer deserializer = new JsonDeserializer();
var response = new RestResponse();
response.Content = content;
MessageContent messageContent = null;
try {
messageContent = deserializer.Deserialize<MessageContent>(response);
} catch {
MessageContent = null;
}
if (messageContent != null) {
MessageContent = messageContent;
if (Event == "message" || Event == "comment") {
ExtractedBody = messageContent.Text;
}
} else if(Event == "message") {
ExtractedBody = content;
}
Displayable = ExtractedBody != null;
TimeStamp = UnixTimeToLocal(Sent);
}
开发者ID:pratik136,项目名称:Flowdock.NET,代码行数:27,代码来源:Message.cs
示例5: TestReadTrelloExport
public void TestReadTrelloExport()
{
var contents = File.ReadAllText("..\\..\\..\\..\\Data\\Trello\\testExport.json");
var x = new JsonDeserializer();
var dato = SimpleJson.DeserializeObject<Board>(contents);
}
开发者ID:nickntg,项目名称:workablemigrationhelpers,代码行数:7,代码来源:Scratch.cs
示例6: JSONDeserializationTest
public void JSONDeserializationTest() {
var path = Path.Combine(Environment.CurrentDirectory, "User.json");
var ds = new JsonDeserializer();
var response = new RestResponse() { ContentType = "application/json", ResponseStatus = ResponseStatus.Completed, StatusCode = System.Net.HttpStatusCode.OK };
// Read the file as one string.
StreamReader myFile = new StreamReader(path);
string json = myFile.ReadToEnd();
myFile.Close();
response.Content = json;
var myUser = ds.Deserialize<User>(response);
Assert.IsNotNull(myUser);
Assert.AreEqual("PT23IWX", myUser.id);
Assert.AreEqual("Tim Wright", myUser.name);
Assert.AreEqual("[email protected]", myUser.email);
Assert.AreEqual("Eastern Time (US & Canada)", myUser.time_zone);
Assert.AreEqual("purple", myUser.color);
Assert.AreEqual("owner", myUser.role);
Assert.AreEqual("https://secure.gravatar.com/avatar/923a2b907dc04244e9bb5576a42e70a7.png?d=mm&r=PG", myUser.avatar_url);
Assert.AreEqual("/users/PT23IWX", myUser.user_url);
Assert.AreEqual(false, myUser.invitation_sent);
Assert.AreEqual(false, myUser.marketing_opt_out);
}
开发者ID:jameswestbv,项目名称:PagerDuty.Net,代码行数:28,代码来源:UserTests.cs
示例7: ReplayAllEvents
public void ReplayAllEvents()
{
using (IDocumentSession session = _eventStorage.OpenSession())
{
int startPos = 0;
while (true)
{
RavenQueryStatistics stats;
var events = session.Query<EventDescriptor>()
.Statistics(out stats)
.OrderBy(ev => ev.AggregateId)
.ThenBy(ev => ev.Version)
.Select(ev => ev)
.Skip(startPos)
.ToArray();
JsonDeserializer deserializer = new JsonDeserializer();
foreach (EventDescriptor ev in events)
{
Publish(deserializer.Deserialize(ev.EventType, ev.EventData));
}
if (stats.TotalResults <= startPos)
{
break;
}
startPos += 128;
}
}
}
开发者ID:Erls-Corporation,项目名称:Logos,代码行数:35,代码来源:RavenDbEventStore.cs
示例8: JiraRestClient
public JiraRestClient(string baseUrl, string username, string password)
{
this.username = username;
this.password = password;
deserializer = new JsonDeserializer();
client = new RestClient { BaseUrl = new Uri(baseUrl + (baseUrl.EndsWith("/") ? "" : "/") + "rest/api/2/") };
}
开发者ID:richard-green,项目名称:Gallifrey,代码行数:7,代码来源:JiraRestClient.cs
示例9: JSONDeserializationTest
public void JSONDeserializationTest() {
var path = Path.Combine(Environment.CurrentDirectory, "Schedule.json");
var ds = new JsonDeserializer();
var response = new RestResponse() { ContentType = "application/json", ResponseStatus = ResponseStatus.Completed, StatusCode = System.Net.HttpStatusCode.OK };
// Read the file as one string.
StreamReader myFile = new StreamReader(path);
string json = myFile.ReadToEnd();
myFile.Close();
response.Content = json;
var mySchedule = ds.Deserialize<Schedule>(response);
Assert.IsNotNull(mySchedule);
Assert.IsNotNull(mySchedule.escalation_policies);
Assert.AreEqual("FS4LEQD", mySchedule.id);
Assert.AreEqual("24x7 Schedule", mySchedule.name);
Assert.AreEqual("UTC", mySchedule.time_zone);
Assert.AreEqual(new DateTime(635726880000000000), mySchedule.today);
Assert.AreEqual(1, mySchedule.escalation_policies.Count);
Assert.AreEqual("PAD5HK6", mySchedule.escalation_policies[0].id);
Assert.AreEqual("Escalation Policy - 24x7", mySchedule.escalation_policies[0].name);
}
开发者ID:Famien,项目名称:PagerDuty.Net,代码行数:25,代码来源:ScheduleTests.cs
示例10: JSONDeserializationTest
public void JSONDeserializationTest() {
var path = Path.Combine(Environment.CurrentDirectory, "Incident.json");
var ds = new JsonDeserializer();
var response = new RestResponse() { ContentType = "application/json", ResponseStatus = ResponseStatus.Completed, StatusCode = System.Net.HttpStatusCode.OK };
// Read the file as one string.
StreamReader myFile = new StreamReader(path);
string json = myFile.ReadToEnd();
myFile.Close();
response.Content = json;
var myAlert = ds.Deserialize<Incident>(response);
Assert.IsNotNull(myAlert);
Assert.IsNotNull(myAlert.service);
Assert.IsNotNull(myAlert.last_status_change_by);
Assert.AreEqual("1", myAlert.incident_number);
Assert.AreEqual(new DateTime(634830005610000000), myAlert.created_on);
Assert.AreEqual("resolved", myAlert.status);
Assert.AreEqual("https://acme.pagerduty.com/incidents/P2A6J96", myAlert.html_url);
Assert.AreEqual(null, myAlert.incident_key);
Assert.AreEqual(null, myAlert.assigned_to_user);
Assert.AreEqual("https://acme.pagerduty.com/incidents/P2A6J96/log_entries/P2NQP6P", myAlert.trigger_details_html_url);
Assert.AreEqual(new DateTime(634830006590000000), myAlert.last_status_change_on);
}
开发者ID:jameswestbv,项目名称:PagerDuty.Net,代码行数:27,代码来源:IncidentTests.cs
示例11: FetchDiff
public bool FetchDiff (Push push)
{
string url = null;
try {
string response = CachingFetcher.FetchDiff (push.CHAuthID, push.Repository.Owner.Name, push.Repository.Name, ID, out url);
if (response == null)
return false;
var jdes = new JsonDeserializer ();
var wrapper = jdes.Deserialize<CommitWithDiffJsonWrapper> (response);
if (wrapper != null) {
var diff = wrapper.Commit;
if (!diff.FetchBlobs (push)) {
Log (LogSeverity.Error, "Failed to fetch blobs for commit '{0}' from URL '{1}'", ID, url);
return false;
}
Diff = diff;
} else {
Log (LogSeverity.Error, "Failed to fetch diff for commit '{0}' from URL '{1}'", ID, url);
return false;
}
} catch (Exception ex) {
Log (ex, "Exception while fetching diff for commit '{4}' from URL '{5}'\n{0}", ID, url);
return false;
}
CommitWithDiff ret = Diff;
if (ret == null)
Log (LogSeverity.Info, "FetchDiff did not fail, but no diff retrieved?");
return ret != null;
}
开发者ID:nsavga,项目名称:CaptainHook,代码行数:32,代码来源:Commit.cs
示例12: TestDeserializeChannelResult
public void TestDeserializeChannelResult()
{
var doc = File.ReadAllText(Path.Combine("Resources", "channels.json"));
var json = new JsonDeserializer();
var output = json.Deserialize<ChannelResult>(new RestResponse {Content = doc});
Assert.NotNull(output);
Assert.NotNull(output.Channels);
Assert.AreEqual(1, output.Channels.Count);
Assert.AreEqual("CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", output.Channels[0].Sid);
Assert.AreEqual("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", output.Channels[0].AccountSid);
Assert.AreEqual("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", output.Channels[0].ServiceSid);
Assert.AreEqual("my channel", output.Channels[0].FriendlyName);
Assert.IsEmpty(output.Channels[0].Attributes);
Assert.AreEqual("system", output.Channels[0].CreatedBy);
Assert.AreEqual("public", output.Channels[0].Type);
Assert.AreEqual(
"http://localhost/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
output.Channels[0].Url);
Dictionary<string, string> dictionary = output.Channels[0].Links;
Assert.NotNull(dictionary);
Assert.True(dictionary.ContainsKey("members"));
Assert.True(dictionary.ContainsKey("messages"));
Assert.AreEqual(
"http://localhost/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members",
dictionary["members"]);
Assert.AreEqual(
"http://localhost/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages",
dictionary["messages"]);
}
开发者ID:SnapMD,项目名称:twilio-csharp,代码行数:30,代码来源:ChannelTests.cs
示例13: GetParams
public static SinusModel GetParams()
{
var request = new RestRequest(Method.GET);
request.Resource = "model/" + ModelId;
IRestResponse response = client.Execute (request);
var json = new JsonDeserializer();
return json.Deserialize<SinusModel>(response);
}
开发者ID:TomasKulhanek,项目名称:Physio.FmiRestService,代码行数:8,代码来源:SinusSimulator.cs
示例14: AccessTokenClient
/// <summary>
/// Initializes a new instance of the <see cref="AccessTokenClient"/> class.
/// </summary>
/// <param name="serverConfiguration">The client configuration.</param>
/// <exception cref="System.ArgumentNullException">clientConfiguration</exception>
public AccessTokenClient(OAuthServerConfiguration serverConfiguration)
{
Requires.NotNull(serverConfiguration, "clientConfiguration");
this.jsonDeserializer = new JsonDeserializer();
this.serverConfiguration = serverConfiguration;
this.RestClient = new RestClient(serverConfiguration.BaseUrl.ToString());
}
开发者ID:rvanlaarhoven,项目名称:OAuth2.Mobile,代码行数:13,代码来源:AccessTokenClient.cs
示例15: Deserialize_SerializationRepresentation_DeserializedObject
public void Deserialize_SerializationRepresentation_DeserializedObject()
{
var subject = new JsonDeserializer();
var deserialized = subject.Deserialize<Serializable>(Serializable.JsonString("s", 3m));
Assert.That(deserialized.D, Is.EqualTo(3m));
Assert.That(deserialized.S, Is.EqualTo("s"));
}
开发者ID:dgg,项目名称:testing-commons,代码行数:8,代码来源:JsonDeserializerTester.cs
示例16: testDeserializeListResponse
public void testDeserializeListResponse()
{
var doc = File.ReadAllText(Path.Combine("Resources", "task_queues_statistics.json"));
var json = new JsonDeserializer();
var output = json.Deserialize<TaskQueueStatisticsResult>(new RestResponse { Content = doc });
Assert.NotNull(output);
}
开发者ID:SnapMD,项目名称:twilio-csharp,代码行数:8,代码来源:TaskQueueStatisticsTests.cs
示例17: testDeserializeResponse
public void testDeserializeResponse()
{
var doc = File.ReadAllText(Path.Combine("Resources", "workspace_statistics.json"));
var json = new JsonDeserializer();
var output = json.Deserialize<WorkspaceStatistics>(new RestResponse { Content = doc });
Assert.NotNull(output);
}
开发者ID:SnapMD,项目名称:twilio-csharp,代码行数:8,代码来源:WorkspaceStatisticsTests.cs
示例18: testDeserializeInstanceResponse
public void testDeserializeInstanceResponse()
{
var doc = Twilio.Api.Tests.Utilities.UnPack(BASE_NAME + "worker_statistics.json");
var json = new JsonDeserializer();
var output = json.Deserialize<WorkerStatistics>(new RestResponse { Content = doc });
Assert.NotNull(output);
}
开发者ID:mrockmann,项目名称:twilio-dotnet,代码行数:8,代码来源:WorkerStatisticsTests.cs
示例19: FanartTV
public FanartTV(string apiKey)
{
ApiKey = apiKey;
Error = null;
Timeout = null;
Deserializer = new JsonDeserializer();
Generator = new RequestGenerator(apiKey);
}
开发者ID:GreenOnyx,项目名称:Ember-MM-Newscraper,代码行数:9,代码来源:FanartTV.cs
示例20: RottenTomatoes
public RottenTomatoes(string apiKey)
{
ApiKey = apiKey;
Error = null;
Timeout = null;
Deserializer = new JsonDeserializer();
Generator = new RequestGenerator(apiKey);
}
开发者ID:rgls,项目名称:Ember-MM-New,代码行数:9,代码来源:RottenTomatoes.cs
注:本文中的JsonDeserializer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论