I have a JSON asset with a root array:
[
{
"word": "word",
"label": "label"
},
{
"word": "word2",
"label": "label2"
}
]
I'm trying to parse it using Klaxon.
So far I have tried several methods:
val wordDict = Klaxon().parse<List<DictWord>>( activity.assets.open("dict.json") )
val wordDict = Klaxon().parse<Array<DictWord>>( activity.assets.open("dict.json") )
val wordDict = Klaxon().parse<JsonArray<DictWord>>( activity.assets.open("dict.json") )
Which either result in an empty list or an exception:
java.lang.ClassCastException: com.beust.klaxon.JsonArray cannot be cast to com.beust.klaxon.JsonObject
What am I doing wrong?