在uwp中格式化json字符串控件

时间:2017-10-16 14:12:22

标签: uwp

uwp中是否有一个控件可以将json字符串格式化为更易读?

我的意思是如果我有一个像

这样的字符串

enter image description here

我希望控件将其格式化为

enter image description here

1 个答案:

答案 0 :(得分:1)

您可以解析字符串。在其中插入一个新行,x:Bind将此方法添加到TextBlock.Text

    private string ParseString(string jsonString)
    {
        return jsonString.Replace(",", ",\n").Replace("{", "{\n").Replace("}", "\n}");
    }