Skip to content

qoncept/kaja

Repository files navigation

Kaja

Kaja is a type-safe JSON parser/decoder for Kotlin inspired by Argo and SwiftyJSON.

val json: Result<Json, JsonException>
    = Json.parse(jsonString)

val person: Result<Person, JsonException>
    = curry(::Person) mp
        json["firstName"].string ap
        json["middleName"].string.optional ap
        json["lastName"].string ap
        json["age"].int ap
        json["knownFor"].list(Json::string)

The code above is one to parse JSONs formatted like the following

{
    "firstName": "Albert",
    "lastName": "Einstein",
    "age": 76,
    "knownFor": [
        "General relativity",
        "Special relativity",
        "Photoelectric effect",
        "Mass-energy equivalence",
        "Theory of Brownian motion"
    ]
}

and decode it to a Person.

data class Person(
    val firstName: String,
    val middleName: String?,
    val lastName: String,
    val age: Int,
    val knownFor: List<String>
)

Naming

Kaja is derived from caja (box) in Spanish. Kaja's K and j stand for Kotlin and JSON respectively.

License

The MIT License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages