https://kotlinlang.org logo
#android
Title
# android
k

katien

12/21/2017, 12:36 AM
so, to represent error responses with a format like this:
Copy code
{
  "errors": {
    "first_name": [
      "first name is required"
    ],
    "last_name": [
      "last name is required"
    ],
    "image": [
      "Invalid image format"
    ]
  },
  "message": "Invalid profile data",
  "status": 400
}
I parse my json into this response model:
Copy code
data class ErrorResponse (
        var errors: Map<String, List<String>> = emptyMap(),
        var status: Int = 0) {
    operator fun get(k: String): List<String>? = errors[k]
}
😂 1
s

silentsudo

12/21/2017, 1:40 PM
you must keep address of ws developer in case something goes wrong.
2 Views