0

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.

seba123neo
  • 4,688
  • 10
  • 35
  • 53
  • 2
    Since the JSON string comming from the internet site is invalid, you cannot do much about it. Contact the webmaster and tell him the problem. The author has to correct it, not the consumer (you). – Olivier Jacot-Descombes Aug 19 '12 at 21:22
  • actually this is not an error generated from the web, web only thing it does is bring me the title of the post published, and in the post titles can come in double quotes, the error is JSON. but I think this can be solved programmatically. – seba123neo Aug 19 '12 at 21:35
  • Have a look at Regular Expressions - it sound like a problem that they could solve easily. – Michael Rodrigues Aug 19 '12 at 23:39

1 Answers1

1

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.

Olivier Jacot-Descombes
  • 104,806
  • 13
  • 138
  • 188