我有一个像这样的字符串:
{"label":{"en":"Africa","de":"Afrika"},"description":{"en":"continent","de":"irdischer Kontinent"}}
可以将其转换为列表,如下所示:
"label" - "en":"Africa","de":"Afrika"
"description" - "en":"continent","de":"irdischer Kontinent"
谢谢
我有一个像这样的字符串:
{"label":{"en":"Africa","de":"Afrika"},"description":{"en":"continent","de":"irdischer Kontinent"}}
"label" - "en":"Africa","de":"Afrika"
"description" - "en":"continent","de":"irdischer Kontinent"
谢谢
正如其他人所建议的那样,您似乎正在尝试处理JSON文档。我建议使用Json.NET。
然而,如果转换非常简单且输入变化不大,则可以仅操作字符串本身。一种简单的方法是这样做:
var result = input.Replace(":{", " - ")
.Replace("},", Environment.NewLine)
.Replace("{", string.Empty)
.Replace("}", string.Empty);