|
@@ -8,9 +8,10 @@
|
|
|
|
|
|
package org.elasticsearch.gradle.internal.doc
|
|
|
|
|
|
-import groovy.json.JsonException
|
|
|
-import groovy.json.JsonParserType
|
|
|
-import groovy.json.JsonSlurper
|
|
|
+import com.fasterxml.jackson.core.JsonFactory;
|
|
|
+import com.fasterxml.jackson.core.JsonParser;
|
|
|
+import com.fasterxml.jackson.core.JsonParseException;
|
|
|
+import com.fasterxml.jackson.core.JsonToken;
|
|
|
|
|
|
import org.gradle.api.DefaultTask
|
|
|
import org.gradle.api.InvalidUserDataException
|
|
@@ -118,15 +119,20 @@ class SnippetsTask extends DefaultTask {
|
|
|
.replaceAll(/([:,])\s*(\$[^ ,\n}]+)/, '$1 "$2"')
|
|
|
// quote fields starting with $
|
|
|
.replaceAll(/(\$[^ ,\n}]+)\s*:/, '"$1":')
|
|
|
- JsonSlurper slurper =
|
|
|
- new JsonSlurper(type: JsonParserType.INDEX_OVERLAY)
|
|
|
+
|
|
|
+ JsonFactory jf = new JsonFactory();
|
|
|
+ jf.configure(JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER,true);
|
|
|
+ JsonParser jsonParser;
|
|
|
+
|
|
|
try {
|
|
|
- slurper.parseText(quoted)
|
|
|
- } catch (JsonException e) {
|
|
|
- throw new InvalidUserDataException("Invalid json "
|
|
|
- + "in $snippet. The error is:\n${e.message}.\n"
|
|
|
- + "After substitutions and munging, the json "
|
|
|
- + "looks like:\n$quoted", e)
|
|
|
+ jsonParser = jf.createParser(quoted);
|
|
|
+ while(jsonParser.isClosed() == false) {
|
|
|
+ jsonParser.nextToken();
|
|
|
+ }
|
|
|
+ } catch (JsonParseException e) {
|
|
|
+ throw new InvalidUserDataException("Invalid json in "
|
|
|
+ + snippet.toString() + ". The error is:\n" + e.getMessage() + ".\n"
|
|
|
+ + "After substitutions and munging, the json looks like:\n" + quoted, e);
|
|
|
}
|
|
|
}
|
|
|
perSnippet(snippet)
|