C# JSON使用的常用技巧(一)

获取JSON无格式的字符串:

new JArray().ToString(Newtonsoft.Json.Formatting.None);

如:

{"A":123,"B":456}

 

获取JSON缩进格式的字符串:

new JArray().ToString(Newtonsoft.Json.Formatting.Indented);

如:

{
    "A":123,
    "B":456
}

 

在获取JSON的时候默认是缩进的格式。

 

posted on 2016-06-28 14:40  shaozhuyong  阅读(600)  评论(0编辑  收藏  举报