Trim json string in JSON.NET

廉价感情. 提交于 2019-12-10 22:42:12

问题


I am using JObject.ToString() method to convert JSON object to string. But how can I trim output to delete spaces between tokens?


回答1:


No need to resort to using Regex. Just use the Formatting.None option:

string json = jObject.ToString(Formatting.None);



回答2:


JsonConvert.SerializeObject(myJson);

Json.Net SerializeObject



来源:https://stackoverflow.com/questions/28454026/trim-json-string-in-json-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!