Type Extensions for Klaxon (Kotlin JSON library)
- Long
- Int
- Enum
- Date
Get Long, Double, Float, String as Int, without loosing precision when it is convertable
val i = jsonObject.intStrict("fieldName")
Get Int, Double, Float or String as Long, when it is convertable
val l = jsonObject.intStrict("fieldName")
Convert any string to enum:
val e = jsonObject.enum<EnumType>("fieldName")
val e = jsonObject.enumFromValues("fieldName", Enum.values())
val e = jsonObject.enumFromFunction("fieldName", {f->function(f)})
Get any whole Numeric as Date
val e = jsonObject.date("fieldName")
ext4klaxon is under development.
Gradle:
compile 'com.fboldog.ext4klaxon:ext4klaxon:0.3.1'
or Maven:
<dependency>
<groupId>com.fboldog.ext4klaxon</groupId>
<artifactId>ext4klaxon</artifactId>
<version>0.3.1</version>
</dependency>