繁体   English   中英

如何在SQL或C#中从json中删除\\“

[英]how can I remove \" from json in SQL or c#

我想将JSON保存到SQL Server,并且可以将其读取为文本,而没有\\ r \\ n和\\“

保存到数据库的代码:

JObject data=...
objTableA.fieldA= data.ToString(Newtonsoft.Json.Formatting.None);

使用此代码,当我读取objTableA.fieldA时,它没有\\ r \\ n,但问题是,我可以在结果中看到\\“

那我该怎么解决

好结果:

{"userId":"75","IsComment":"true","IsCommentReply":"true","IsLikes":"true","IsFollow":"true","IsCommercial":"true","IsMention":"true","IsNewMember":"true"}

错误的结果:

{\"userId\":\"75\",\"IsComment\":\"true\",\"IsCommentReply\":\"true\",\"IsLikes\":\"true\",\"IsFollow\":\"true\",\"IsCommercial\":\"true\",\"IsMention\":\"true\",\"IsNewMember\":\"true\"}

如果要将字符串转换为json对象。

尝试这个

var data = "{\"userId\":\"75\",\"IsComment\":\"true\",\"IsCommentReply\":\"true\",\"IsLikes\":\"true\",\"IsFollow\":\"true\",\"IsCommercial\":\"true\",\"IsMention\":\"true\",\"IsNewMember\":\"true\"}";

JObject parseData = JObject.Parse(data);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM