0

I'm using Google Gson 2.3.1 library.
When I receive the following json string:

 {"PC" : "Domain\Host"}

I receive in POJO DomainHost string without backslash. What is the correct way to deal with it?

  1. Ask from serializer man to add an escape backslash like that Domain\\Host?
  2. Check for backslashes on my side and insert escaping backslash prior to deserializing?
  3. Maybe GSON library know to deal with it?

Didn't find anything not in manual neither in google that can help me. Currently I tend to choose 2nd option, but not sure that it's a good idea.

Thank you.

Nomesh DeSilva
  • 1,649
  • 4
  • 25
  • 43
Anatoly
  • 5,056
  • 9
  • 62
  • 136
  • 2
    What you have there is not valid JSON. I'm surprised Gson even accepts to parse it. Fix the code which generates this JSON. – JB Nizet May 31 '15 at 10:48
  • 1
    see this: http://stackoverflow.com/questions/19176024/how-to-escape-special-characters-in-building-a-json-string –  May 31 '15 at 10:49
  • @JBNizet, thank you! Your comment should be answer, and I'd accepted it. – Anatoly May 31 '15 at 10:58

0 Answers0