0

I need to show json string in the textbox. It came from db as string and drops after first quote.

If I replace with single quiot:

jsonString.Replace("\"", "'")

it works but show single string instead.

I tried this answer:

jsonString.Replace("\"", "\\\"")

but it doesn't work.

How i can show double quotes. I use C#, not JavaScript.

PS. I can't post real json, but lets take some very simple:

{ "name":"John" }

Technology: web application MVC4, controller uses repository to get data and then show it in cshtml view.

Alexan
  • 8,165
  • 14
  • 74
  • 101
  • 1
    post your json string – Rahul Jun 12 '20 at 17:39
  • more info would help. what technology do you use? winform/webform/wpf/javascript? How do you currently setting the json in the textbox? – TGN12 Jun 12 '20 at 17:46
  • How are you "showing it in a textbox"? Can you show the code that accomplishes this thing? – Lasse V. Karlsen Jun 12 '20 at 17:59
  • Please review [MCVE] guidelines on posting code and [edit] question accordingly. No one knows why you DB query does not even return complete JSON... or maybe it does and you confuse everyone but instead figured out how to incorrectly render text in HTML (I mean it requires effort to render text incorrectly in HTML... but some people just like it `Raw`) – Alexei Levenkov Jun 12 '20 at 19:08

1 Answers1

1

The following code resolved this problem:

jsonString.Replace("\"", """)
Alexan
  • 8,165
  • 14
  • 74
  • 101