private CmsSpellcheckingRequest parseJsonRequest(JSONObject jsonRequest) {

        final String id = jsonRequest.optString(JSON_ID);

        final JSONObject params = jsonRequest.optJSONObject(JSON_PARAMS);

        if (null == params) {
            LOG.debug("Invalid JSON request: No field \"params\" defined. ");
            return null;
        }
        final JSONArray words = params.optJSONArray(JSON_WORDS);
        final String lang = params.optString(JSON_LANG, LANG_DEFAULT);
        if (null == words) {
            LOG.debug("Invalid JSON request: No field \"words\" defined. ");
            return null;
        }

        // Convert JSON array to array of type String
        final List<String> wordsToCheck = new LinkedList<String>();
        for (int i = 0; i < words.length(); i++) {
            final String word = words.opt(i).toString();
            wordsToCheck.add(word);

            if (Character.isUpperCase(word.codePointAt(0))) {
                wordsToCheck.add(word.toLowerCase());
            }
        }

        return new CmsSpellcheckingRequest(wordsToCheck.toArray(new String[wordsToCheck.size()]), lang, id);
    }
private CmsSpellcheckingRequest parseJsonRequest ( JSONObject jsonRequest ) { final String id = jsonRequest . optString ( JSON_ID ) ; final JSONObject params = jsonRequest . optJSONObject ( JSON_PARAMS ) ; if ( null == params ) { LOG . debug ( "Invalid JSON request: No field \"params\" defined. " ) ; return null ; } final JSONArray words = params . optJSONArray ( JSON_WORDS ) ; final String lang = params . optString ( JSON_LANG , LANG_DEFAULT ) ; if ( null == words ) { LOG . debug ( "Invalid JSON request: No field \"words\" defined. " ) ; return null ; } final List < String > wordsToCheck = new LinkedList < String > ( ) ; for ( int i = 0 ; i < words . length ( ) ; i ++ ) { final String word = words . opt ( i ) . toString ( ) ; wordsToCheck . add ( word ) ; if ( Character . isUpperCase ( word . codePointAt ( 0 ) ) ) { wordsToCheck . add ( word . toLowerCase ( ) ) ; } } return new CmsSpellcheckingRequest ( wordsToCheck . toArray ( new String [ wordsToCheck . size ( ) ] ) , lang , id ) ; }
Parse JSON parameters from this request.

@param jsonRequest The request in the JSON format.
@return CmsSpellcheckingRequest object that contains parsed parameters or null, if JSON input is not well
defined.