Prabhu
Prabhu

Reputation: 13335

Escaping quotes in json string

JavaScriptSerializer s = new JavaScriptSerializer();
result = s.Deserialize<Hashtable>(data);

Error is thrown if data is

"{a:\"\"test\" 123\",b:\"hello\" }" 

No error is thrown if data is

"{a:\"test 123\",b:\"hello\" }"

How do I adjust the data string so that no error is thrown even when there are quotes?

Upvotes: 0

Views: 6358

Answers (1)

Razor Storm
Razor Storm

Reputation: 12326

That shouldn't happen but try single quotes?

"{a:\"'test' 123\",b:\"hello\" }"

Or this:

'{a:"\"test\"" 123",b:"hello" }'

Upvotes: 1

Related Questions