}
}
private static JsonNode buildParsingError(final JsonProcessingException e,
final boolean crlf) {
final JsonLocation location = e.getLocation();
final ObjectNode ret = JsonNodeFactory.instance.objectNode();
/*
* Unfortunately, for some reason, Jackson botches the column number in
* its JsonPosition -- I cannot figure out why exactly. However, it does
* have a correct offset into the buffer.
*
* The problem is that if the input has CR/LF line terminators, its
* offset will be "off" by the number of lines minus 1 with regards to
* what JavaScript sees as positions in text areas. Make the necessary
* adjustments so that the caret jumps at the correct position in this
* case.
*/
final int lineNr = location.getLineNr();
int offset = (int) location.getCharOffset();
if (crlf)
offset = offset - lineNr + 1;
ret.put(ParseError.LINE, lineNr);
ret.put(ParseError.OFFSET, offset);