Created
August 21, 2018 15:34
-
-
Save KravaDanil/8551bd1eca9d899e532d9c16a3bd300c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val str = if (json.has("errors") && json.getJSONArray("errors").length() > 0 && | |
| (json.getJSONArray("errors").get(0) as JSONObject).length() > 0 && | |
| (json.getJSONArray("errors").get(0) as JSONObject).keys().hasNext()) { | |
| val errorsObj = json.getJSONArray("errors").get(0) as JSONObject | |
| errorsObj.keys() | |
| .asSequence() | |
| .map { errorsObj.getString(it) } | |
| .joinToString("\n") | |
| } else if (json.has("error_description")) { | |
| json.getString("error_description") | |
| } else if (json.has("message")) { | |
| json.getString("message") | |
| } else { | |
| errorString | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment