httpClient = new HttpClient();
stringContent = new HttpStringContent(postBody, UnicodeEncoding.Utf8, "application/json");
httpResponse = await httpClient.PostAsync(uri, stringContent);
String responseString = await httpResponse.Content.ReadAsStringAsync();
编写UWP应用程序并尝试将JSON数据发送到Web服务器。在我对象序列化到JSON postBody = JsonConvert.SerializeObject(parentModel);
另一种方法,我得到有效的JSON:HttpStringContent使JSON无效?
"{\"ParentId\":\"[email protected]\",\"ParentPrimaryId\":\"[email protected]\",\"ParentPassword\":\"n78mG2LB18ANtzr7gd2X/fILNELjbjOMuTWbhWoDvcg=\",\"ParentFirstName\":\"Bill\",\"ParentLastName\":\"Gates\",\"AddChildDistrictId\":\"\",\"RemoveChildDistrictId\":\"\",\"ParentToken\":null,\"ParentDistrictId\":\"\",\"ParentChildDistricts\":\"\",\"AppPlatform\":\"Windows 10.0.15063.138\",\"AppVersion\":10000,\"ParentAccountStatus\":1,\"ParentStatusCode\":0,\"ParentFailedSignInAttempt\":0}"
然而,当我通过后身体HttpStringContent,它给了我:
{{"ParentId":"[email protected]","ParentPrimaryId":"[email protected]","ParentPassword":"n78mG2LB18ANtzr7gd2X/fILNELjbjOMuTWbhWoDvcg=","ParentFirstName":"Bill","ParentLastName":"Gates","AddChildDistrictId":"","RemoveChildDistrictId":"","ParentToken":null,"ParentDistrictId":"","ParentChildDistricts":"","AppPlatform":"Windows 10.0.15063.138","AppVersion":10000,"ParentAccountStatus":1,"ParentStatusCode":0,"ParentFailedSignInAttempt":0}}
这是无效的JSON 。这是什么被发送?为什么它会添加额外的大括号并删除开头的引号?
当你说“它给了我”时,它到底是什么?请解释你如何得到那个输出。 –