user5740086
user5740086

Reputation: 39

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

I want to save JSON to SQL Server and can read it as a text without \r\n and \"

Code of saving to DataBase:

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

with this code, when I read objTableA.fieldA it gives me without \r\n, but the problem is , I can see \" in my result

So how can I solve it

good result:

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

wrong result:

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

Upvotes: 0

Views: 200

Answers (1)

reza.cse08
reza.cse08

Reputation: 6178

If you want to convert a string to json object.

try this

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

JObject parseData = JObject.Parse(data);

Upvotes: 1

Related Questions