Example usage for org.json JSONObject getBoolean

List of usage examples for org.json JSONObject getBoolean

Introduction

In this page you can find the example usage for org.json JSONObject getBoolean.

Prototype

public boolean getBoolean(String key) throws JSONException 

Source Link

Document

Get the boolean value associated with a key.

Usage

From source file:com.hichinaschool.flashcards.anki.Preferences.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // Workaround for bug 4611: http://code.google.com/p/android/issues/detail?id=4611
    if (AnkiDroidApp.SDK_VERSION >= 7 && AnkiDroidApp.SDK_VERSION <= 10) {
        Themes.applyTheme(this, Themes.THEME_ANDROID_DARK);
    }/*from   ww  w .  jav a  2 s .co  m*/
    super.onCreate(savedInstanceState);

    mCol = AnkiDroidApp.getCol();
    mPrefMan = getPreferenceManager();
    mPrefMan.setSharedPreferencesName(AnkiDroidApp.SHARED_PREFS_NAME);

    addPreferencesFromResource(R.xml.preferences);

    swipeCheckboxPreference = (CheckBoxPreference) getPreferenceScreen().findPreference("swipe");
    zoomCheckboxPreference = (CheckBoxPreference) getPreferenceScreen().findPreference("zoom");
    keepScreenOnCheckBoxPreference = (CheckBoxPreference) getPreferenceScreen().findPreference("keepScreenOn");
    showAnswerCheckBoxPreference = (CheckBoxPreference) getPreferenceScreen().findPreference("timeoutAnswer");
    animationsCheckboxPreference = (CheckBoxPreference) getPreferenceScreen().findPreference("themeAnimations");
    useBackupPreference = (CheckBoxPreference) getPreferenceScreen().findPreference("useBackup");
    asyncModePreference = (CheckBoxPreference) getPreferenceScreen().findPreference("asyncMode");
    eInkDisplayPreference = (CheckBoxPreference) getPreferenceScreen().findPreference("eInkDisplay");
    fadeScrollbars = (CheckBoxPreference) getPreferenceScreen().findPreference("fadeScrollbars");
    //        ListPreference listpref = (ListPreference) getPreferenceScreen().findPreference("theme");
    convertFenText = (CheckBoxPreference) getPreferenceScreen().findPreference("convertFenText");
    fixHebrewText = (CheckBoxPreference) getPreferenceScreen().findPreference("fixHebrewText");
    syncAccount = (Preference) getPreferenceScreen().findPreference("syncAccount");
    showEstimates = (CheckBoxPreference) getPreferenceScreen().findPreference("showEstimates");
    showProgress = (CheckBoxPreference) getPreferenceScreen().findPreference("showProgress");
    learnCutoff = (NumberRangePreference) getPreferenceScreen().findPreference("learnCutoff");
    timeLimit = (NumberRangePreference) getPreferenceScreen().findPreference("timeLimit");
    useCurrent = (ListPreference) getPreferenceScreen().findPreference("useCurrent");
    newSpread = (ListPreference) getPreferenceScreen().findPreference("newSpread");
    dayOffset = (SeekBarPreference) getPreferenceScreen().findPreference("dayOffset");
    //        String theme = listpref.getValue();
    //        animationsCheckboxPreference.setEnabled(theme.equals("2") || theme.equals("3"));
    zoomCheckboxPreference.setEnabled(!swipeCheckboxPreference.isChecked());

    initializeLanguageDialog();
    initializeCustomFontsDialog();

    if (mCol != null) {
        // For collection preferences, we need to fetch the correct values from the collection
        mStartDate = GregorianCalendar.getInstance();
        Timestamp timestamp = new Timestamp(mCol.getCrt() * 1000);
        mStartDate.setTimeInMillis(timestamp.getTime());
        dayOffset.setValue(mStartDate.get(Calendar.HOUR_OF_DAY));
        try {
            JSONObject conf = mCol.getConf();
            learnCutoff.setValue(conf.getInt("collapseTime") / 60);
            timeLimit.setValue(conf.getInt("timeLim") / 60);
            showEstimates.setChecked(conf.getBoolean("estTimes"));
            showProgress.setChecked(conf.getBoolean("dueCounts"));
            newSpread.setValueIndex(conf.getInt("newSpread"));
            useCurrent.setValueIndex(conf.getBoolean("addToCur") ? 0 : 1);
        } catch (JSONException e) {
            throw new RuntimeException();
        } catch (NumberFormatException e) {
            throw new RuntimeException();
        }
    } else {
        // It's possible to open the preferences from the loading screen if no SD card is found.
        // In that case, there will be no collection loaded, so we need to disable the settings
        // that read from and write to the collection.
        dayOffset.setEnabled(false);
        learnCutoff.setEnabled(false);
        timeLimit.setEnabled(false);
        showEstimates.setEnabled(false);
        showProgress.setEnabled(false);
        newSpread.setEnabled(false);
        useCurrent.setEnabled(false);
    }

    for (String key : mShowValueInSummList) {
        updateListPreference(key);
    }
    for (String key : mShowValueInSummSeek) {
        updateSeekBarPreference(key);
    }
    for (String key : mShowValueInSummEditText) {
        updateEditTextPreference(key);
    }
    for (String key : mShowValueInSummNumRange) {
        updateNumberRangePreference(key);
    }

    if (AnkiDroidApp.SDK_VERSION <= 4) {
        fadeScrollbars.setChecked(false);
        fadeScrollbars.setEnabled(false);
    }
}

From source file:net.dahanne.gallery3.client.utils.ItemUtils.java

private static Entity parseJSONToEntity(JSONObject jsonResult) throws JSONException {
    Entity entity = new Entity();
    JSONObject entityJSON = jsonResult.getJSONObject("entity");

    entity.setId(entityJSON.getInt("id"));
    entity.setCaptured(entityJSON.getString("captured").equals("null") ? 0L
            : Integer.parseInt(entityJSON.getString("captured")));
    entity.setCreated(entityJSON.getString("created").equals("null") ? 0
            : Integer.parseInt(entityJSON.getString("created")));
    entity.setDescription(entityJSON.getString("description"));
    entity.setHeight(entityJSON.getString("height").equals("null") ? 0
            : Integer.parseInt(entityJSON.getString("height")));
    entity.setLevel(entityJSON.getInt("level"));
    entity.setMimeType(//from  w  ww.j a  v a  2 s .c o m
            entityJSON.getString("mime_type").equals("null") ? null : entityJSON.getString("mime_type"));
    entity.setName(entityJSON.getString("name").equals("null") ? null : entityJSON.getString("name"));
    entity.setOwnerId(entityJSON.getString("owner_id").equals("null") ? 0
            : Integer.parseInt(entityJSON.getString("owner_id")));
    entity.setRandKey(entityJSON.getString("rand_key").equals("null") ? 0f
            : Float.parseFloat(entityJSON.getString("rand_key")));
    entity.setResizeHeight(entityJSON.getString("resize_height").equals("null") ? 0
            : Integer.parseInt(entityJSON.getString("resize_height")));
    entity.setResizeWidth(entityJSON.getString("resize_width").equals("null") ? 0
            : Integer.parseInt(entityJSON.getString("resize_width")));
    entity.setSlug(entityJSON.getString("slug").equals("null") ? null : entityJSON.getString("slug"));
    entity.setSortColumn(entityJSON.getString("sort_column"));
    entity.setSortOrder(entityJSON.getString("sort_order"));
    entity.setThumbHeight(entityJSON.getString("thumb_height").equals("null") ? 0
            : Integer.parseInt(entityJSON.getString("thumb_height")));
    entity.setThumbWidth(entityJSON.getString("thumb_width").equals("null") ? 0
            : Integer.parseInt(entityJSON.getString("thumb_width")));
    entity.setTitle(entityJSON.getString("title"));
    entity.setType(entityJSON.getString("type"));
    entity.setUpdated(entityJSON.getString("updated").equals("null") ? 0
            : Integer.parseInt(entityJSON.getString("updated")));
    entity.setViewCount(entityJSON.getInt("view_count"));
    entity.setWidth(
            entityJSON.getString("width").equals("null") ? 0 : Integer.parseInt(entityJSON.getString("width")));
    entity.setView1(entityJSON.getInt("view_1"));
    entity.setView2(entityJSON.getInt("view_2"));
    entity.setWebUrl(entityJSON.getString("web_url"));
    try {
        entity.setThumbUrl(
                entityJSON.getString("thumb_url").equals("null") ? null : entityJSON.getString("thumb_url"));
    } catch (JSONException e) {
        // nothing to do, it's just that there is no thumb url
    }
    try {
        entity.setThumbSize(entityJSON.getInt("thumb_size"));
    } catch (JSONException e) {
        // nothing to do, it's just that there is no thumb size
    }
    try {
        entity.setThumbUrlPublic(entityJSON.getString("thumb_url_public"));
    } catch (JSONException e) {
        // nothing to do, it's just that there is no thumb url public
    }
    try {
        entity.setParent(ItemUtils.getItemIdFromUrl(entityJSON.getString("parent")));
    } catch (JSONException e) {
        // nothing to do, it's just that there is no parent
    }
    entity.setCanEdit(entityJSON.getBoolean("can_edit"));

    if (entity.getType().equals("album")) {
        try {
            entity.setAlbumCover(entityJSON.getString("album_cover"));
        } catch (JSONException e) {
            // nothing to do, it's just that there is no album_cover
        }
    }

    if (entity.getType().equals("photo")) {
        entity.setFileUrl(entityJSON.getString("file_url"));
        entity.setFileSize(entityJSON.getInt("file_size"));
        try {
            entity.setFileUrlPublic(entityJSON.getString("file_url_public"));
        } catch (JSONException e) {
            // nothing to do, it's just that there is no album_cover
        }
        entity.setResizeUrl(entityJSON.getString("resize_url"));
        try {
            entity.setResizeSize(entityJSON.getInt("resize_size"));
        } catch (JSONException e) {
            // nothing to do, it's just that there is no album_cover
        }
        try {
            entity.setResizeUrlPublic(entityJSON.getString("resize_url_public"));
        } catch (JSONException e) {
            // nothing to do, it's just that there is no album_cover
        }
    }

    return entity;
}

From source file:se.su.dsv.scipro.android.tasks.LoginAsyncTask.java

@Override
protected LoginResult doInBackground(Void... params) {
    String response = SciProJSON.getInstance().jsonLogin(username, password);

    boolean authenticated = false;
    String apikey = "";
    long userid = -1;
    try {//from ww  w .jav a  2 s. c  om
        JSONObject jsonObject = new JSONObject(response);
        authenticated = jsonObject.getBoolean("authenticated");
        if (authenticated) {
            apikey = jsonObject.getString("apikey");
            userid = jsonObject.getLong("userid");
        }
    } catch (JSONException e) {
        Log.e(TAG, "JSONException: ", e);
    }

    return new LoginResult(authenticated, username, apikey, userid);
}

From source file:com.mparticle.internal.ConfigManager.java

public synchronized void updateConfig(JSONObject responseJSON, boolean persistJson) throws JSONException {
    SharedPreferences.Editor editor = mPreferences.edit();
    if (persistJson) {
        saveConfigJson(responseJSON);//from   w w  w.  ja  v a  2  s.  co m
    }

    if (responseJSON.has(KEY_UNHANDLED_EXCEPTIONS)) {
        mLogUnhandledExceptions = responseJSON.getString(KEY_UNHANDLED_EXCEPTIONS);
    }

    if (responseJSON.has(KEY_PUSH_MESSAGES)) {
        sPushKeys = responseJSON.getJSONArray(KEY_PUSH_MESSAGES);
        editor.putString(KEY_PUSH_MESSAGES, sPushKeys.toString());
    }

    mRampValue = responseJSON.optInt(KEY_RAMP, -1);

    if (responseJSON.has(KEY_OPT_OUT)) {
        mSendOoEvents = responseJSON.getBoolean(KEY_OPT_OUT);
    } else {
        mSendOoEvents = false;
    }

    if (responseJSON.has(ProviderPersistence.KEY_PERSISTENCE)) {
        setProviderPersistence(new ProviderPersistence(responseJSON, mContext));
    } else {
        setProviderPersistence(null);
    }

    mSessionTimeoutInterval = responseJSON.optInt(KEY_SESSION_TIMEOUT, -1);
    mUploadInterval = responseJSON.optInt(KEY_UPLOAD_INTERVAL, -1);

    mTriggerMessageMatches = null;
    mTriggerMessageHashes = null;
    if (responseJSON.has(KEY_TRIGGER_ITEMS)) {
        try {
            JSONObject items = responseJSON.getJSONObject(KEY_TRIGGER_ITEMS);
            if (items.has(KEY_MESSAGE_MATCHES)) {
                mTriggerMessageMatches = items.getJSONArray(KEY_MESSAGE_MATCHES);
            }
            if (items.has(KEY_TRIGGER_ITEM_HASHES)) {
                mTriggerMessageHashes = items.getJSONArray(KEY_TRIGGER_ITEM_HASHES);
            }
        } catch (JSONException jse) {

        }

    }

    if (responseJSON.has(KEY_INFLUENCE_OPEN)) {
        mInfluenceOpenTimeout = responseJSON.getLong(KEY_INFLUENCE_OPEN) * 60 * 1000;
    } else {
        mInfluenceOpenTimeout = 30 * 60 * 1000;
    }

    mRestrictAAIDfromLAT = responseJSON.optBoolean(KEY_AAID_LAT, true);
    mIncludeSessionHistory = responseJSON.optBoolean(KEY_INCLUDE_SESSION_HISTORY, true);
    if (responseJSON.has(KEY_DEVICE_PERFORMANCE_METRICS_DISABLED)) {
        MParticle.setDevicePerformanceMetricsDisabled(
                responseJSON.optBoolean(KEY_DEVICE_PERFORMANCE_METRICS_DISABLED, false));
    }

    editor.apply();
    applyConfig();

    MParticle.getInstance().getKitManager().updateKits(responseJSON.optJSONArray(KEY_EMBEDDED_KITS));
}

From source file:com.mparticle.internal.ConfigManager.java

public boolean shouldTrigger(MPMessage message) {
    JSONArray messageMatches = getTriggerMessageMatches();
    JSONArray triggerHashes = getTriggerMessageHashes();

    //always trigger for PUSH_RECEIVED
    boolean shouldTrigger = message.getMessageType().equals(Constants.MessageType.PUSH_RECEIVED)
            || message.getMessageType().equals(Constants.MessageType.COMMERCE_EVENT);

    if (!shouldTrigger && messageMatches != null && messageMatches.length() > 0) {
        shouldTrigger = true;/* w w w  .j a  va  2 s.  c  om*/
        int i = 0;
        while (shouldTrigger && i < messageMatches.length()) {
            try {
                JSONObject messageMatch = messageMatches.getJSONObject(i);
                Iterator<?> keys = messageMatch.keys();
                while (shouldTrigger && keys.hasNext()) {
                    String key = (String) keys.next();
                    shouldTrigger = message.has(key);
                    if (shouldTrigger) {
                        try {
                            shouldTrigger = messageMatch.getString(key)
                                    .equalsIgnoreCase(message.getString(key));
                        } catch (JSONException stringex) {
                            try {
                                shouldTrigger = message.getBoolean(key) == messageMatch.getBoolean(key);
                            } catch (JSONException boolex) {
                                try {
                                    shouldTrigger = message.getDouble(key) == messageMatch.getDouble(key);
                                } catch (JSONException doubleex) {
                                    shouldTrigger = false;
                                }
                            }
                        }
                    }
                }
            } catch (Exception e) {

            }
            i++;
        }
    }
    if (!shouldTrigger && triggerHashes != null) {
        for (int i = 0; i < triggerHashes.length(); i++) {
            try {
                if (triggerHashes.getInt(i) == message.getTypeNameHash()) {
                    shouldTrigger = true;
                    break;
                }
            } catch (JSONException jse) {

            }
        }
    }
    return shouldTrigger;
}

From source file:produvia.com.scanner.RegisterActivity.java

@Override
public void onTaskCompleted(final int flag, final JSONObject json) {

    runOnUiThread(new Runnable() {
        @Override//from  www.  j  a va 2s .  c om
        public void run() {
            try {

                if (json.getBoolean("success")) {
                    Intent intent = new Intent(RegisterActivity.this, DevicesActivity.class);
                    startActivity(intent);
                    finish();
                } else {
                    if (json.has("info"))
                        Toast.makeText(RegisterActivity.this, json.getString("info"), Toast.LENGTH_LONG).show();
                }
            } catch (Exception e) {
                //usually if the emmail is already taken:
                Toast.makeText(RegisterActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
            }
        }
    });

}

From source file:com.roiland.crm.sm.core.service.impl.DriveTestAPIImpl.java

@Override
public Boolean updateDriveTest(String userID, String dealerOrgID, DriveTest driveTest)
        throws ResponseException {

    try {/* w w  w.ja  va2  s. co  m*/
        if (userID == null || dealerOrgID == null) {
            throw new ResponseException("userID or dealerOrgID is null.");
        }
        // ?
        JSONObject params = new JSONObject();
        params.put("userID", userID);
        params.put("dealerOrgID", dealerOrgID);
        params.put("projectID", driveTest.getProjectID());
        params.put("driveTestID", driveTest.getDriveTestID());
        params.put("driverName", driveTest.getDriverName());
        params.put("driverMobile", driveTest.getDriverMobile());
        params.put("driverLicenseNo", driveTest.getDriverLicenseNo());
        params.put("driveChassisNo", driveTest.getDriveChassisNo());
        params.put("driveLicensePlate", driveTest.getDriveLicensePlate());
        params.put("driveStatus", driveTest.getDriveStatus());
        params.put("driveStartTime", driveTest.getDriveStartTime());
        params.put("driveEndTime", driveTest.getDriveEndTime());
        params.put("driveStartKM", driveTest.getDriveStartKM());
        params.put("driveEndKM", driveTest.getDriveEndKM());
        params.put("driveComment", driveTest.getDriveComment());

        RLHttpResponse response = getHttpClient()
                .executePostJSON(getURLAddress(URLContact.METHOD_UPDATE_DRIVETEST), params, null);
        boolean success;
        if (response.isSuccess()) {
            JSONObject result = new JSONObject(getSimpleString(response)).getJSONObject("result");

            // ??
            success = (result.getBoolean("success"));

            return success;
        }
        throw new ResponseException();
    } catch (IOException e) {
        Log.e(tag, "Connection network error.", e);
        throw new ResponseException(e);
    } catch (JSONException e) {
        Log.e(tag, "Parsing data error.", e);
        throw new ResponseException(e);
    } catch (Exception e) {
        throw new ResponseException(e);
    }
}

From source file:se.su.dsv.scipro.android.tasks.AuthAsyncTask.java

@Override
protected LoginResult doInBackground(Void... params) {
    String response = SciProJSON.getInstance().jsonAuth(username, apikey);

    boolean authenticated = false;
    String apikey = "";
    long userid = -1;
    try {//from w w w .  ja  v  a 2s  . co m
        JSONObject jsonObject = new JSONObject(response);
        authenticated = jsonObject.getBoolean("authenticated");
        if (authenticated) {
            apikey = jsonObject.getString("apikey");
            userid = jsonObject.getLong("userid");
        }
    } catch (JSONException e) {
        Log.e(TAG, "JSONException: ", e);
    }

    return new LoginResult(authenticated, username, apikey, userid);
}

From source file:com.gmail.at.faint545.adapters.RemoteQueueAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = ((LayoutInflater) mContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE))
                .inflate(resourceID, null);
        ViewHolder viewHolder = new ViewHolder();
        viewHolder.filename = (TextView) convertView.findViewById(R.id.remote_queue_row_filename);
        viewHolder.status = (TextView) convertView.findViewById(R.id.remote_queue_row_status);
        viewHolder.checkBox = (CheckBox) convertView.findViewById(R.id.remote_queue_checkbox);
        viewHolder.progressBar = (ProgressBar) convertView.findViewById(R.id.remote_queue_progress_bar);
        convertView.setTag(viewHolder);/*from   ww  w .  ja v  a  2s.c  o  m*/
    }

    JSONObject job = jobs.get(position);
    if (job != null) {
        ViewHolder viewHolder = (ViewHolder) convertView.getTag();
        StringBuilder jobStatus = new StringBuilder();
        String statusText = null, filename = null;
        double mbLeft = 0, mbTotal = 0;
        Boolean isChecked = false;

        try {
            mbLeft = job.getDouble(SabnzbdConstants.MBLEFT);
            mbTotal = job.getDouble(SabnzbdConstants.MB);
            statusText = job.getString(SabnzbdConstants.STATUS);
            filename = job.getString(SabnzbdConstants.FILENAME);
            isChecked = job.getBoolean("checked");
        } catch (JSONException e) {
            // Do nothing
        }

        jobStatus.append(statusText).append(", ").append(StringUtils.normalizeSize(mbLeft, "m"))
                .append(" left of ").append(StringUtils.normalizeSize(mbTotal, "m"));

        viewHolder.checkBox.setChecked(isChecked);
        viewHolder.filename.setText(filename);
        viewHolder.status.setText(jobStatus.toString());
        viewHolder.progressBar.setMax((int) mbTotal);
        viewHolder.progressBar.setProgress((int) (mbTotal - mbLeft));
    }
    return convertView;
}

From source file:cc.redpen.server.api.RedPenResource.java

/**
 * Validate a request encoded in JSON. Valid properties are:
 * <p>/*from  www  . j  a va 2 s . co  m*/
 * document : the source text of the document
 * documentParser : specifies one of PLAIN, WIKI, or MARKDOWN
 * lang : the source document language (en, ja, etc)
 * format : the format of the results, eg: json, json2, plain etc
 * config : the redpen validator configuration
 *
 * @param requestJSON the request, in JSON
 * @return redpen validation errors
 * @throws RedPenException when failed to validate the json
 */
@Path("/validate/json")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
@WinkAPIDescriber.Description("Process a redpen JSON validation request and returns any redpen errors")
public Response validateDocumentJSON(JSONObject requestJSON) throws RedPenException {

    LOG.info("Validating document using JSON request");
    String documentParser = getOrDefault(requestJSON, "documentParser", DEFAULT_DOCUMENT_PARSER);
    String documentText = getOrDefault(requestJSON, "document", "");
    String format = getOrDefault(requestJSON, "format", DEFAULT_FORMAT);

    String lang = DEFAULT_LANG;

    Map<String, Map<String, String>> properties = new HashMap<>();
    JSONObject config = null;
    if (requestJSON.has("config")) {
        try {
            config = requestJSON.getJSONObject("config");
            lang = getOrDefault(config, "lang", DEFAULT_LANG);
            if (config.has("validators")) {
                JSONObject validators = config.getJSONObject("validators");
                Iterator keyIter = validators.keys();
                while (keyIter.hasNext()) {
                    String validator = String.valueOf(keyIter.next());
                    Map<String, String> props = new HashMap<>();
                    properties.put(validator, props);
                    JSONObject validatorConfig = validators.getJSONObject(validator);
                    if ((validatorConfig != null) && validatorConfig.has("properties")) {
                        JSONObject validatorProps = validatorConfig.getJSONObject("properties");
                        Iterator propsIter = validatorProps.keys();
                        while (propsIter.hasNext()) {
                            String propname = String.valueOf(propsIter.next());
                            props.put(propname, validatorProps.getString(propname));
                        }
                    }
                }
            }
        } catch (Exception e) {
            LOG.error("Exception when processing JSON properties", e);
        }
    }

    RedPen redPen = new RedPenService(context).getRedPen(lang, properties);

    // override any symbols
    if ((config != null) && config.has("symbols")) {
        try {
            JSONObject symbols = config.getJSONObject("symbols");
            Iterator keyIter = symbols.keys();
            while (keyIter.hasNext()) {
                String symbolName = String.valueOf(keyIter.next());
                try {
                    SymbolType symbolType = SymbolType.valueOf(symbolName);
                    JSONObject symbolConfig = symbols.getJSONObject(symbolName);
                    Symbol originalSymbol = redPen.getConfiguration().getSymbolTable().getSymbol(symbolType);
                    if ((originalSymbol != null) && (symbolConfig != null) && symbolConfig.has("value")) {
                        String value = symbolConfig.has("value") ? symbolConfig.getString("value")
                                : String.valueOf(originalSymbol.getValue());
                        boolean spaceBefore = symbolConfig.has("before_space")
                                ? symbolConfig.getBoolean("before_space")
                                : originalSymbol.isNeedBeforeSpace();
                        boolean spaceAfter = symbolConfig.has("after_space")
                                ? symbolConfig.getBoolean("after_space")
                                : originalSymbol.isNeedAfterSpace();
                        String invalidChars = symbolConfig.has("invalid_chars")
                                ? symbolConfig.getString("invalid_chars")
                                : String.valueOf(originalSymbol.getInvalidChars());
                        if ((value != null) && !value.isEmpty()) {
                            redPen.getConfiguration().getSymbolTable().overrideSymbol(new Symbol(symbolType,
                                    value.charAt(0), invalidChars, spaceBefore, spaceAfter));
                        }
                    }

                } catch (IllegalArgumentException iae) {
                    LOG.error("Ignoring unknown SymbolType " + symbolName);
                }
            }
        } catch (Exception e) {
            LOG.error("Exception when processing JSON symbol overrides", e);
        }
    }
    Document parsedDocument = redPen.parse(DocumentParser.of(documentParser), documentText);

    List<ValidationError> errors = redPen.validate(parsedDocument);

    Formatter formatter = FormatterUtils.getFormatterByName(format);

    if (formatter == null) {
        throw new RedPenException(
                "Unsupported format: " + format + " - please use xml, plain, plain2, json or json2");
    }

    return responseTyped(formatter.format(parsedDocument, errors), format);
}