0

In a Play 2.0 application, I need to deserialize some JSON from a source which I don't control which uses single-quotes around strings -- where the JSON spec calls for double-quotes.

The solution using Jackson is here: Configure Jackson to deserialize single quoted (invalid) JSON

But trying to implement this solution in play2.0 I hit a wall of static objects and private classes... it should be enough to replace object JerksonJson with one implementing the solution linked above at initialization, but because it is a static object it can't be extended, and id I try to copy it into my code I need to drag along classes PlaySerializers, PlayDeserializers, JsValueDeserializer,... I stopped here, as it looked like too much.

Is there a clean solution?

Community
  • 1
  • 1
jsalvata
  • 2,155
  • 15
  • 32

2 Answers2

0

How about trying to fix the invalid json string by replacing every ' in it with a "?

That would work if 's are only used for specifying strings.

Pouria
  • 159
  • 12
  • I finally used a Regex to replace all ' not preceded by a \ with a " -- after having replaced all " with \". Then I replaced all \' with '. Not pretty, but worked. The original question stands to be answered, though. – jsalvata Aug 01 '13 at 23:36
0

I realize that this may not help too much with Play framework part, but perhaps you could use Jackson Scala Module instead of Jerkson? Doing that should make it easier to just use ObjectMapper, with Scala module registered, instead of having to use Jerkson-specific handlers.

StaxMan
  • 113,358
  • 34
  • 211
  • 239