public static String serialize(Query query, String insertBeforeGrouping) {
        StringBuilder out = new StringBuilder();
        serialize(query.getModel().getQueryTree().getRoot(), out);
        out.append(insertBeforeGrouping);
        for (GroupingRequest request : query.getSelect().getGrouping()) {
            out.append(" | ");
            serialize(request, out);
        }
        return out.toString();
    }
Do YQL+ escaping, which is basically the same as for JSON, of the
incoming string to the "quoted" buffer. The buffer returned is the same
as the one given in the "quoted" parameter.

@param in a string to escape
@param escaped the target buffer for escaped data
@return the same buffer as given in the "quoted" parameter
container-search/src/main/java/com/yahoo/search/yql/VespaSerializer.java