0

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\"}
2
  • 1
    A sample of the JSON data would be useful
    – Ghasem
    Commented May 9, 2016 at 5:03
  • Where should I find this sample :) Commented May 9, 2016 at 5:08

1 Answer 1

1

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);
1
  • Thank you, this is what I want :) Commented May 9, 2016 at 5:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.