VIVO-719 Fix an error in the JSON parsing.

This commit is contained in:
Jim Blake 2014-06-06 17:46:50 -04:00
parent aa1df06ac2
commit c05a3a857a
2 changed files with 1748 additions and 1 deletions

View file

@ -75,9 +75,10 @@ public class JsonToNquads extends OutputStream {
String text = buffer.toString("UTF-8"); String text = buffer.toString("UTF-8");
boolean inQuotes = false; boolean inQuotes = false;
int braceLevel = 0; int braceLevel = 0;
char previous = 0;
for (char c : text.toCharArray()) { for (char c : text.toCharArray()) {
if (inQuotes) { if (inQuotes) {
if (c == '"') { if ((c == '"') && (previous != '\\')) {
inQuotes = false; inQuotes = false;
} }
} else { } else {
@ -89,6 +90,7 @@ public class JsonToNquads extends OutputStream {
braceLevel--; braceLevel--;
} }
} }
previous = c;
} }
return (braceLevel == 0) && (text.endsWith(",") || text.endsWith("]")); return (braceLevel == 0) && (text.endsWith(",") || text.endsWith("]"));
} }