小编Tom*_*Tom的帖子

将JSON响应流转换为字符串

我正在尝试POST,然后将JSON响应读入字符串.

我相信我的问题是我需要将自己的对象传递给DataContractJsonSerializer,但我想知道是否有某种方法可以将响应转换为关联数组或某种键/值格式.

我的JSON格式如下:{"license":"AAAA-AAAA-AAAA-AAAA"},我的代码如下:

using (Stream response = HttpCommands.GetResponseStream(URL, FormatRegistrationPost(name, email)))
{
   string output = new StreamReader(response).ReadToEnd();
   response.Close();

   DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(string));
   MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(output));
   string results = json.ReadObject(ms) as string;

   licenseKey = (string) results.GetType().GetProperty("license").GetValue(results, null);
}
Run Code Online (Sandbox Code Playgroud)

谢谢!

.net c# json

4
推荐指数
1
解决办法
3万
查看次数

如何使用word interop确定两个word文档是否相同

有没有一种好方法可以使用单词interop查看两个文档是否相同?

我尝试过使用类似的东西:

Word.Document tempDoc = app.CompareDocuments(document1, document2);
Run Code Online (Sandbox Code Playgroud)

我的问题是tempDoc如果相同则不为null,所以我不确定如何使用此结果来确定文档是否相同.

提前致谢!

c# com office-interop

2
推荐指数
1
解决办法
1068
查看次数

标签 统计

c# ×2

.net ×1

com ×1

json ×1

office-interop ×1