c# json 排版

public static string PraseToJson(string json)
{
try
{
JsonSerializer s = new JsonSerializer();
JsonReader reader = new JsonTextReader(new StringReader(json));
Object jsonObject = s.Deserialize(reader);
StringWriter sWriter = new StringWriter();
JsonWriter writer = new JsonTextWriter(sWriter);
writer.Formatting = Formatting.Indented;
s.Serialize(writer, jsonObject);
return sWriter.ToString();
}
catch (Exception ex)
{
return json;
}
}

posted @ 2015-11-05 15:43  小川丶  阅读(743)  评论(0编辑  收藏  举报