@César Oliveira - your JSON string, resposta has an escape sequence that VS does not recognize. The "\U" within the JSON string is not supported. You should change the \U to \U.
Json and exception System.ArgumentException: 'Escape sequence not recognized.. (48):
Hello People, Good Night,
The code above generate the Exception System.ArgumentException: 'Escape sequence not recognized. (48):
Dim resposta As String ="{"SUCCESS":0,"IDERRO":1,"ERRO":"O CAMPO NOME \U00E9 OBRIGAT\U00F3RIO"}"
Dim obj As Object = New JavaScriptSerializer().Deserialize(Of Object)(resposta.ToString())
How i solve the problem ?
Thank you
César Oliveira
5 answers
Sort by: Most helpful
-
-
César Oliveira 1 Reputation point
2020-09-15T21:48:43.827+00:00 Not is possíble.
This json came of WebService
I can't change the jsonHow i solve the problema in vb.net ?
Thank you
-
Dylan Zhu-MSFT 6,416 Reputation points
2020-09-16T02:52:06.423+00:00 Hi @César Oliveira ,
You could use Chrw() function to recognize escape sequence in visual basic, which is like:
"O CAMPO NOME \U00E9 OBRIGAT\U00F3RIO"
->"O CAMPO NOME" + ChrW(&HE9) + " OBRIGAT" + ChrW(&HF3) + "RIO"
Best Regards,
Dylan -
César Oliveira 1 Reputation point
2020-09-16T10:30:08.457+00:00 No, i cant change the code json.
it is necessary manipulate the variable resposta to acept the Escape sequence not recognizedI tried other code but not work, it generate another exception. The code is:
Dim resposta As String ="{"SUCCESS":0,"IDERRO":1,"ERRO":"O CAMPO NOME \U00E9 OBRIGAT\U00F3RIO"}"
Dim stream = New MemoryStream(Encoding.UTF8.GetBytes(resposta.ToString()))
Dim obj As Object = New JavaScriptSerializer().Deserialize(Of MensagemErro)(stream.toString())The exeption is System.ArgumentException: 'Invalid JSON primitive: System.IO.MemoryStream.'
Thank you
-
César Oliveira 1 Reputation point
2020-09-17T11:54:55.797+00:00 Thank you for all people,
i solve the problem
it is easy
i convent the variable restultado to Lowercase. it work now.
Thank you