我有以下 JSON:
{ "Test": {"Header": {"Description": "OK", "Status": "000", "Timestamp": "1338805752" }, "Results": {"Sport": {"Country": { "League": [ {"Name": "ECB 40 League", "TargetURL": "\/Cricket\/International\/ECB 40 League", "Total": "5" }, {"Name": "Friends Life T20 2012", "TargetURL": "\/Cricket\/International\/Friends Life T20 2012", "Total": "0" }, {"Name": "Sri Lanka vs Pakistan (ODI Series)", "TargetURL": "\/Cricket\/International\/Sri Lanka vs Pakistan (ODI Series)", "Total": "0" }, {"Name": "Sri Lanka vs Pakistan 1st ODI", "TargetURL": "\/Cricket\/International\/Sri Lanka vs Pakistan 1st ODI", "Total": "1" }, {"Name": "Test Series", "TargetURL": "\/Cricket\/International\/Test Series", "Total": "1" } ], "Name": "International", "TargetURL": "\/Cricket\/International", "Total": "6" }, "Name": "Cricket", "Total": "5" } } }}
当我从我的 C# 代码中返回它时,我是这样得到的:
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">{ "HotOdds": {"Header": {"Description": "OK", "Status": "000", "Timestamp": "1338805752" }, "Results": {"Sport": {"Country": { "League": [ {"Name": "ECB 40 League", "TargetURL": "\/Cricket\/International\/ECB 40 League", "Total": "5" }, {"Name": "Friends Life T20 2012", "TargetURL": "\/Cricket\/International\/Friends Life T20 2012", "Total": "0" }, {"Name": "Sri Lanka vs Pakistan (ODI Series)", "TargetURL": "\/Cricket\/International\/Sri Lanka vs Pakistan (ODI Series)", "Total": "0" }, {"Name": "Sri Lanka vs Pakistan 1st ODI", "TargetURL": "\/Cricket\/International\/Sri Lanka vs Pakistan 1st ODI", "Total": "1" }, {"Name": "Test Series", "TargetURL": "\/Cricket\/International\/Test Series", "Total": "1" } ], "Name": "International", "TargetURL": "\/Cricket\/International", "Total": "6" }, "Name": "Cricket", "Total": "5" } } }}</string>
这是函数的定义:
[OperationContract(Name = "GetHOSports")]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
string GetSportsList(DateTime date, int sportID);
我不明白为什么我要在 XML 元素中获取 JSON,有人吗?