Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Странный разбор ответа в HTTPClient.java #51

Open
elagin opened this issue Sep 27, 2015 · 2 comments
Open

Странный разбор ответа в HTTPClient.java #51

elagin opened this issue Sep 27, 2015 · 2 comments
Assignees
Labels

Comments

@elagin
Copy link
Owner

elagin commented Sep 27, 2015

Попался на глаза такой кусок. Зачем два раза reader = new JSONObject делаем?

        try {
            reader = new JSONObject(response.toString());
        } catch (JSONException e) {
            e.printStackTrace();
            try {
                reader = new JSONObject(response.toString().replace("\\", "").replace("\"", ""));
            } catch (JSONException e1) {
                e1.printStackTrace();
                String fakeAnswer = "{ isError : unknown }";
                try {
                    reader = new JSONObject(fakeAnswer);
                } catch (JSONException e2) {
                    //Абсолютно маловероятно
                    e2.printStackTrace();
                    reader = new JSONObject();
                }
            }
        }
@elagin
Copy link
Owner Author

elagin commented Sep 27, 2015

Чтобы быстрее работало?

@rjhdby
Copy link
Collaborator

rjhdby commented Oct 4, 2015

Для чего сделано - не помню, но логика такая. Если ответ не разобрался - пробуем удалить из него все обратные слеши и разобрать снова, если и это не помогло - возвращаем ошибку, если ошибку вернули с ошибкой - возвращаем пустой json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants