现在有一段java的代码
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(requestUrl);
JSONObject response = null;
String encoderJson = URLEncoder.encode(json.toString(), HTTP.UTF_8);
StringEntity string = new StringEntity(encoderJson);
string.setContentEncoding("UTF-8");
string.setContentType("application/json");
post.setEntity(string);
HttpResponse res = client.execute(post);
if (res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
HttpEntity entity = res.getEntity();
response = new JSONObject(new JSONTokener(new InputStreamReader(entity.getContent(), CHAR_SET)));
我要用c#写一个webapi方法来接收上面java返回的json格式的数据怎么写,重点是方法里面怎么接收?
.Net Core 下的简单写法,使用.Net Framework 的话,会有一定的差别,JObject使用的是 Newtonsoft.Json 的