Use a SimpleJsonSerializer in the FileSplitter (#3262)

* Use a SimpleJsonSerializer in the FileSplitter

* To avoid extra dependency for Jackson when we
serialize `FileSplitter.FileMarker` to JSON, use
a `SimpleJsonSerializer` instead.
* Fix `SimpleJsonSerializer` to escape a `\` symbol from property values
since it is used for quoting string values in the final JSON

* * Document the change
This commit is contained in:
Artem Bilan
2020-04-27 15:42:45 -04:00
committed by GitHub
parent 620b9bf52d
commit cfd03f89a0
5 changed files with 23 additions and 19 deletions

View File

@@ -22,6 +22,7 @@ import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Matcher;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -99,7 +100,7 @@ public final class SimpleJsonSerializer {
return result.toString();
}
else {
return "\"" + (result == null ? "null" : result.toString()) + "\"";
return "\"" + (result == null ? "null" : Matcher.quoteReplacement(result.toString())) + "\"";
}
}