in src/main/java/org/apache/sling/contentparser/json/internal/JSONTicksConverter.java [38:96]
static String tickToDoubleQuote(final String input) {
final int len = input.length();
final StringBuilder output = new StringBuilder(len);
boolean quoted = false;
boolean tickQuoted = false;
boolean escaped = false;
boolean comment = false;
char lastChar = ' ';
for (int i = 0; i < len; i++) {
char in = input.charAt(i);
if (quoted || tickQuoted) {
if (escaped) {
if (in != '\'') {
output.append("\\");
}
if (in == '\\') {
output.append("\\");
}
escaped = false;
} else {
if (in == '"') {
if (quoted) {
quoted = false;
} else {
output.append("\\");
}
} else if (in == '\'') {
if (tickQuoted) {
in = '"';
tickQuoted = false;
}
} else if (in == '\\') {
escaped = true;
}
}
} else {
if (comment) {
if (lastChar == '*' && in == '/') {
comment = false;
}
} else {
if (lastChar == '/' && in == '*') {
comment = true;
} else if (in == '\'') {
in = '"';
tickQuoted = true;
} else if (in == '"') {
quoted = true;
}
}
}
if (in == '\\') {
continue;
}
output.append(in);
lastChar = in;
}
return output.toString();
}