【发布时间】:2022-01-14 15:00:32
【问题描述】:
我有一个返回的字符串看起来像这样
"{\"properties\":{\"item1\":{\"dataType\":\"string\"},\"item2\":{\"dataType\":\"string\"}},\"lastModified\":\"2021-12-09T18:20:29Z\"}"
我尝试使用字典进行反序列化,但仍未捕获数据。 最重要的数据只是在属性中命名,item1, item2
System.Text.Json.JsonSerializer.Deserialize<IDictionary<string, object>>(jsonString)
它给出了以下结果
[0] [KeyValuePair]:{[properties, {"Item1":{"dataType":"string"},"item2":{"dataType":"string"}
Key [string]:"properties"
Value [object]:ValueKind = Object : "{"item1":{"dataType":"string"},"item2":{"dataType":"string"}
Key [string]:"lastModified"
[1] [KeyValuePair]:{[lastModified, 2021-12-09T19:00:12Z]}
【问题讨论】:
-
and it' giving the folowing result那么实际的问题是什么? -
如何只捕捉名字? item1 和 item2 等进入字符串列表
-
您可以通过提供您期望得到的示例来改进您的问题。从您所展示的内容来看,反序列化工作正常,但听起来您希望发生一些不同的事情。