Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在WCF中返回有效的JSON数组_C#_Json_Wcf_Rest_Webinvoke - Fatal编程技术网

C# 如何在WCF中返回有效的JSON数组

C# 如何在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

[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"}]