asp还有人用吗_javascript和jsp区别

asp还有人用吗_javascript和jsp区别英文原文There’sanexistingStackOverflowquestionandexamplethatcallsExecuteAsynconRestSharp.NetCore.IsuccessfullyusedthatexamplewhenreferencingRestSharp.NetCore105.2.3withNewtonsoft.Json…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

英文原文

There’s an existing StackOverflow question and example that calls ExecuteAsync on RestSharp.NetCore.

I successfully used that example when referencing RestSharp.NetCore 105.2.3 with Newtonsoft.Json 9.0.2-beta2.

using System.Threading.Tasks;

using Newtonsoft.Json;

using Newtonsoft.Json.Serialization;

using RestSharp;

public async Task TestPost(ObjectFoo foo)

{

JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings {

ContractResolver = new CamelCasePropertyNamesContractResolver()

};

RestClient restClient = new RestClient(API_URL);

RestRequest request = new RestRequest(“SOME_METHOD”, Method.POST);

request.AddHeader(“Accept”, “application/json”);

string jsonObject = JsonConvert.SerializeObject(foo, Formatting.Indented, jsonSerializerSettings);

request.AddParameter(“application/json”, jsonObject, ParameterType.RequestBody);

TaskCompletionSource taskCompletion = new TaskCompletionSource();

RestRequestAsyncHandle handle = restClient.ExecuteAsync(

request, r => taskCompletion.SetResult(r));

RestResponse response = (RestResponse)(await taskCompletion.Task);

return JsonConvert.DeserializeObject(response.Content);

}

中文翻译

现有的StackOverflow问题和示例在RestSharp.NetCore上调用ExecuteAsync。

在使用Newtonsoft.Json 9.0.2-beta2引用RestSharp.NetCore 105.2.3时,我成功使用了该示例。

使用System.Threading.Tasks;

使用Newtonsoft.Json;

使用Newtonsoft.Json.Serialization;

使用RestSharp;

public async Task< SomeObject> TestPost(ObjectFoo foo)

{

JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings {

ContractResolver = new CamelCasePropertyNamesContractResolver()

};

RestClient restClient = new RestClient(API_URL);

RestRequest request = new RestRequest(” SOME_METHOD” ,Method.POST);

request.AddHeader(” Accept” ,” application / json” );

string jsonObject = JsonConvert.SerializeObject(foo,Formatting.Indented,jsonSerializerSettings);

request.AddParameter(” application / json” ,jsonObject,ParameterType.RequestBody);

TaskCompletionSource< IRestResponse> taskCompletion = new TaskCompletionSource< IRestResponse>();

RestRequestAsyncHandle handle = restClient.ExecuteAsync(

请求,r => taskCompletion.SetResult(R));

RestResponse response =(RestResponse)(等待taskCompletion.Task);

返回JsonConvert.DeserializeObject< SomeObject>(response.Content);

}

There’s an existing StackOverflow question and example that calls ExecuteAsync on RestSharp.NetCore.

I successfully used that example when referencing RestSharp.NetCore 105.2.3 with Newtonsoft.Json 9.0.2-beta2.

using System.Threading.Tasks;

using Newtonsoft.Json;

using Newtonsoft.Json.Serialization;

using RestSharp;

public async Task TestPost(ObjectFoo foo)

{

JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings {

ContractResolver = new CamelCasePropertyNamesContractResolver()

};

RestClient restClient = new RestClient(API_URL);

RestRequest request = new RestRequest(“SOME_METHOD”, Method.POST);

request.AddHeader(“Accept”, “application/json”);

string jsonObject = JsonConvert.SerializeObject(foo, Formatting.Indented, jsonSerializerSettings);

request.AddParameter(“application/json”, jsonObject, ParameterType.RequestBody);

TaskCompletionSource taskCompletion = new TaskCompletionSource();

RestRequestAsyncHandle handle = restClient.ExecuteAsync(

request, r => taskCompletion.SetResult(r));

RestResponse response = (RestResponse)(await taskCompletion.Task);

return JsonConvert.DeserializeObject(response.Content);

}

现有的StackOverflow问题和示例在RestSharp.NetCore上调用ExecuteAsync。

在使用Newtonsoft.Json 9.0.2-beta2引用RestSharp.NetCore 105.2.3时,我成功使用了该示例。

使用System.Threading.Tasks;

使用Newtonsoft.Json;

使用Newtonsoft.Json.Serialization;

使用RestSharp;

public async Task< SomeObject> TestPost(ObjectFoo foo)

{

JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings {

ContractResolver = new CamelCasePropertyNamesContractResolver()

};

RestClient restClient = new RestClient(API_URL);

RestRequest request = new RestRequest(” SOME_METHOD” ,Method.POST);

request.AddHeader(” Accept” ,” application / json” );

string jsonObject = JsonConvert.SerializeObject(foo,Formatting.Indented,jsonSerializerSettings);

request.AddParameter(” application / json” ,jsonObject,ParameterType.RequestBody);

TaskCompletionSource< IRestResponse> taskCompletion = new TaskCompletionSource< IRestResponse>();

RestRequestAsyncHandle handle = restClient.ExecuteAsync(

请求,r => taskCompletion.SetResult(R));

RestResponse response =(RestResponse)(等待taskCompletion.Task);

返回JsonConvert.DeserializeObject< SomeObject>(response.Content);

}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/196022.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Chrome 添加自定义搜索引擎「建议收藏」

    Chrome 添加自定义搜索引擎「建议收藏」在Chrome浏览器地址栏输入:chrome://settings/searchEngines进入管理搜索引擎点击其他搜索引擎右上角的“添加”按钮在输入界面自定义你的引擎,比如我这里添加了PIP的清华镜像点,以便于搜索我想要的第三方库该搜索引擎是通过关键字触发的,比如我用的“-pip”关键字在地址栏输入“-pip”,按tab键即可触发…

    2022年7月13日
    45
  • 什么是面向切面编程_简述面向切面编程思想

    什么是面向切面编程_简述面向切面编程思想学习完面向对象编程和面向接口编程,下一步就是面向切面编程,快来mark!

    2025年8月25日
    1
  • sqlserver 视图创建索引_数据库视图可以建立索引吗

    sqlserver 视图创建索引_数据库视图可以建立索引吗文章目录操作前准备一、视图1、创建视图2、更新视图3、删除视图二、索引1、聚集索引2、非聚集索引3、创建索引语法格式:4、删除索引代码全部示例操作前准备一、视图1、创建视图视图(View)是从一个或多个表或其它视图导出的,用来导出视图的表称为基表,导出的视图又称为虚表。在数据库中,只存储视图的定义,不存放视图对应的数据,这些数据仍然存放在原来的基表中。使用视图前,必须先创建视图,创建…

    2022年8月18日
    8
  • 树莓派容易坏吗_树莓派的使用

    树莓派容易坏吗_树莓派的使用清华下载地址下载地址下载地址xshell下载地址③树莓派插入TF卡后,等连接上手机就可查看IP地址2.远程登录①打开后选择新建②软件更新源③系统更新源④开始更新4.图形化显示界面为方便大家更直观的感受,可以下载一个图形化的显示桌面,这里推荐VNC(windows也自带了该功能,因为太卡了故不推荐,想用的可以试试:远程桌面连接)⭐有条件的可以直接连上显示屏使用①VNC的网盘连接,大家直接下载就行②打开树莓派的VNCServer(默认关闭)A.在

    2022年10月9日
    2
  • php中浮点数计算问题

    php中浮点数计算问题

    2021年10月31日
    39
  • 和黑客斗争的 6 天![通俗易懂]

    和黑客斗争的 6 天![通俗易懂]互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找Sql注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都…

    2022年6月11日
    31

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号