C# 如何在WCF中返回有效的JSON数组
这是我的webInvokeC# 如何在WCF中返回有效的JSON数组,c#,json,wcf,rest,webinvoke,C#,Json,Wcf,Rest,Webinvoke,这是我的webInvoke [WebInvoke( Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "{invoice}/{transtype}/" ) ] 我有这个返回码 Dictionary<string, object>
[WebInvoke(
Method = "GET",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "{invoice}/{transtype}/"
)
]
我有这个返回码
Dictionary<string, object> dic = new Dictionary<string, object>();
dic.Add("ApprovalStatus", response.ApprovalStatus);
dic.Add("AuthorizationCode", response.AuthorizationCode);
dic.Add("CardBalance", response.CardBalance);
dic.Add("ErrorMessage", response.ErrorMessage);
dic.Add("InvoiceNumber", response.InvoiceNumber);
return dic;
我怎样才能使它成为一个JSON数组?它是一个有效的JSON数组…@I4V,哦?我想要一些东西{“Data”:[“ApprovalStatus”:“CAPTURED”]},但它不是有效的json。您最好的选择是
{“数据”:[“ApprovalStatus”,“CAPTURED”]}
[{"Key":"ApprovalStatus","Value":"CAPTURED"},{"Key":"AuthorizationCode","Value":"TAS926"},{"Key":"CardBalance","Value":null},{"Key":"ErrorMessage","Value":""},{"Key":"InvoiceNumber","Value":"1"},{"Key":"ReferenceNumber","Value":"313506502708"},{"Key":"UniqueCode","Value":"2704"}]