public static String jsEncodeKey(String pname) { if (RESERVED_KEYWORDS.contains(pname)) return '"' + pname + '"'; for (int i = 0; i < pname.length(); i++) { char c = pname.charAt(i); if (c == '$' || c == '_' || (c >= 'a' && c <= 'z') || c >= 'A' && c <= 'Z') continue; switch (Character.getType(c)) {  case Character.UPPERCASE_LETTER: case Character.LOWERCASE_LETTER: case Character.TITLECASE_LETTER: case Character.MODIFIER_LETTER: case Character.OTHER_LETTER: case Character.LETTER_NUMBER: continue; case Character.NON_SPACING_MARK: case Character.COMBINING_SPACING_MARK: case Character.DECIMAL_DIGIT_NUMBER: case Character.CONNECTOR_PUNCTUATION: if (i > 0)  continue; } return '"' + pname + '"'; } return pname;
public static String jsEncodeKey(String key) { return '"' + key + '"';
    public static String jsEncodeKey(String pname) {        if (RESERVED_KEYWORDS.contains(pname))            return '"' + pname + '"';        for (int i = 0; i < pname.length(); i++) {            char c = pname.charAt(i);            if (c == '$' || c == '_' || (c >= 'a' && c <= 'z') || c >= 'A' && c <= 'Z')                continue;            switch (Character.getType(c)) {                // note: not allowing unquoted escape sequences for now...                case Character.UPPERCASE_LETTER:                case Character.LOWERCASE_LETTER:                case Character.TITLECASE_LETTER:                case Character.MODIFIER_LETTER:                case Character.OTHER_LETTER:                case Character.LETTER_NUMBER:                    continue;                case Character.NON_SPACING_MARK:                case Character.COMBINING_SPACING_MARK:                case Character.DECIMAL_DIGIT_NUMBER:                case Character.CONNECTOR_PUNCTUATION:                    if (i > 0)  continue;            }            return '"' + pname + '"';        }        return pname;    }