0

I am using Jettison in Java for parsing JSON messages, But in some cases JSON contains line break in values hence getting exception.

{
  "errors": {
    "error": [
      {
        "error-message": "values are not unique: 121
/adduser/userid
/adduser/userid",
        "error-urlpath": "/adduser/userid"
      }
    ]
  }
}

Is there any way to ignore line break in values while parsing error message in Java?

Thanks.

Kruti Patel
  • 1,422
  • 2
  • 23
  • 36
Abhij
  • 1,222
  • 4
  • 19
  • 37
  • 2
    It's just not valid JSON - what's creating this JSON? You should really try to fix that instead. If it's broken for line breaks, it may well fail to escape other things... – Jon Skeet Sep 28 '15 at 06:19

1 Answers1

0

You should fix the JSON source as it is invalid (like Jon Skeet posted). The other way (not so elegant) would be to replace all line breaks with "" or " " and try to parse after that.

Seiya
  • 155
  • 1
  • 10