クライアントのコンテンツを取得カント、クライアントにいくつかの処理後に応答した後。これは、Web APIメソッドである</p> <p>..ここでJSONデータはカントー要求とクライアントデータへの応答をポストウェブAPIであるとして、応答を取得したWeb APIへのリクエストをプレゼントするJsonResultデータ
public ActionResult GetBooks(){
...
return new JsonResult()
{
Data = new { draw = draw, recordsFiltered = totalRecords, recordsTotal = totalRecords, data = booklist },
JsonRequestBehavior = JsonRequestBehavior.AllowGet
};
}
、ここでのWeb APIからクライアント取得応答であり、ビューにそれを投稿:
HttpResponseMessage response = client.GetAsync("api/Book/GetBooks/").Result;
JsonResult result = null;
if (response.IsSuccessStatusCode)
{
result = response.Content.ReadAsAsync<JsonResult>().Result;
}
List<Book> booklist = null;
return Json(new { draw = result.Data.draw, recordsFiltered = result.Data.totalRecords, recordsTotal = result.Data.totalRecords, data = result.Data.booklist }, JsonRequestBehavior.AllowGet);
あなたは私がresult.Data.propertyName
でそれらを取得しようとしたができなかった同じプロパティを参照してくださいよう。
私はクライアントメソッドでリターンプロパティ名を変更したくありません。
どうすればよいですか?ここ
は、応答(結果)データがどのように見えるされています。適切なJSON形式で
{{
"draw": "1",
"recordsFiltered": 670,
"recordsTotal": 670,
"data": [
{
"Title": "A Popular Survey of the Old Testament",
"Publisher": "Baker Academic",
"Description": "Illustrated with photos, charts, and maps, and written in their understanding of Old Testament people and events.",
"Authors": [
"Norman L. Geisler"
],
"Id": "579273aa2711d31de88933bd"
},
{
"Title": "A Village on the Moon/Um Povoado Na Lua",
"Publisher": "Trafford Publishing",
"Description": "Since the beginning of time, mankind has looked up at the Moon and wondered. Many have seen figures on that light in the sky and universo. Um grupo de aventureiros se propôs a colonizar esse planeta e aqui está a sua história.",
"Authors": [
"Charles A. Hindley"
],
"Id": "579273aa2711d31de8893438"
}
]
}}
我々はresult.Data.draw
とresult.Data.data[0]
でデータを取得することができますが、この場合には、私は困っています。..
余分なスコープを削除するにはどうすればよいですか?
あなたの質問は不明です。あなたが何を求めているのかは不明です。あなたが削除したい余分な範囲は何ですか – Nkosi
こんにちは、 "{{"二重スコープ..その正しい右.. ..私はそれが起こる理由を理解していないと私はそれを修正することができますどのように – TyForHelpDude
あなたが尋ねている。 – Nkosi