seba123neo
seba123neo

Reputation: 4748

Remove double quote only when inside another double quote (VB.NET)

I'm using the library JSON.NET to bring a JSON string from the web, but the problem is that I get a double quote within a string.

the string that comes from the web is as follows

{"accionObjeto":"post","accionTipo":"comentario","ts":"02:48:55","nick":"seba123neo","userId":"1180918","id":15521634,"accion_name":"Hola","url":"","titulo":"Hola como" estas"}

the string is perfect except the end

here is the problem

"titulo":"Hola como" estas"

I have to remove that double quote, because otherwise the JSON is "invalid"

I've looked everywhere but can not find how to do this, I need only to erase the double quote, but not erase all other quotes in the entire string.

Thanks for your help.

Upvotes: 0

Views: 1242

Answers (1)

Olivier Jacot-Descombes
Olivier Jacot-Descombes

Reputation: 112352

It is not clear from your question whether you are generating the JSON string or if you are downloading it from the web. If you are creating it and the library is not escaping strings correctly, consider escaping them yourself.

This is a list of valid escapes

\b  Backspace (ascii code 08)
\f  Form feed (ascii code 0C)
\n  New line
\r  Carriage return
\t  Tab
\v  Vertical tab
\'  Apostrophe or single quote
\"  Double quote
\\  Backslash caracter

As you can see you would have to escape a double quote by \". Before you code it yourself, look closer into the library you are using. I would be astonished, if it did not provide such functionality.

Upvotes: 1

Related Questions