public static KeyParseResult parseKey(String key) {
        StringBuilder parsed = new StringBuilder(key.length());
        // Hooray for ad-hoc parsing
        int len = key.length();
        int i = 0;
        if (i < len && key.charAt(0) == '{') {
            i = skipWhitespace(key, i + 1, len);
            if (i < len && key.charAt(i) == '"') {
                i = parseQuotedString(key, i + 1, len, parsed);
            } else {
                // No quoting, use all of string until '}' verbatim
                while (i < len && key.charAt(i) != '}') {
                    parsed.append(key.charAt(i));
                    ++i;
                }
            }
            i = skipWhitespace(key, i, len);
            if (i < len && key.charAt(i) == '}') {
                return new KeyParseResult(parsed.toString(), i + 1);
            } else {
                throw new IllegalArgumentException("Key '" + key + "' is incomplete. No matching '}'");
            }
        } else {
            throw new IllegalArgumentException("Key '" + key + "' does not start with '{'");
        }
    }
Parse a field path map key of the form {xyz} or {"xyz"} with optional trailing data.
If the key contains a '}' or '"' character, the key must be in quotes and all
double-quote characters must be escaped. Only '"' chars may be escaped. Any
trailing string data past the '}' is ignored.

@param key Part of a field path that contains a key at its start
@return A parse result containing the parsed/unescaped key and the number
    of input characters the parse consumed. Does not include any characters
    beyond the '}' char.
document/src/main/java/com/yahoo/document/FieldPathEntry.java