private static void serializeWeightedSetContents(StringBuilder destination, String opName,
                                                     WeightedSetItem weightedSet, String optionalAnnotations) {
        boolean addedAnnotations = addAnnotations(destination, weightedSet, optionalAnnotations);
        destination.append(opName).append('(')
                   .append(normalizeIndexName(weightedSet.getIndexName()))
                   .append(", {");
        int initLen = destination.length();
        List<Entry<Object, Integer>> tokens = new ArrayList<>(weightedSet.getNumTokens());
        for (Iterator<Entry<Object, Integer>> i = weightedSet.getTokens(); i.hasNext();) {
            tokens.add(i.next());
        }
        tokens.sort(tokenComparator);
        for (Entry<Object, Integer> entry : tokens) {
            comma(destination, initLen);
            destination.append('"');
            escape(entry.getKey().toString(), destination);
            destination.append("\": ").append(entry.getValue().toString());
        }
        destination.append("})");
        if (addedAnnotations)
            destination.append(")");
    }
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