Questions tagged [klaxon]

Klaxon is a library to parse JSON in Kotlin.

42 questions
5
votes
1 answer

Android Kotlin + Klaxon - Parsing a JSON root array

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 =…
Vaiden
  • 15,728
  • 7
  • 61
  • 91
5
votes
3 answers

Parsing json in Kotlin

I'm trying to parse Json in Kotlin. I'm having a lot of trouble, it seems that a lot of people learn Kotlin after Java... Not me, I'm a Python guy. I got a Kotlin Jupyter Notebook running fairly quickly (https://github.com/ligee/kotlin-jupyter),…
Freek
  • 1,097
  • 2
  • 12
  • 30
3
votes
1 answer

Klaxon Parsing of Nested Arrays

Im trying to parse this file with Klaxon, generally its going well, except I am totally not succeeding in parsing that subarray of features/[Number]/properties/ So my thought is to get the raw string of properties and to parse it seperately with…
pikkuez
  • 310
  • 1
  • 18
2
votes
1 answer

variable of type kotlin.collections.List becomes java.util.Arraylist and causes error

I am trying to create an application with the walt.id API where I get an error stating the variable is expected to be of type kotlin.collections.List but it is of type java.util.ArrayList even though the variable is of the right…
noobianov
  • 83
  • 6
2
votes
1 answer

Klaxon not reading JSONObject inside JSON

I have an API that returns a JSON object in this format { "success": true, "data": [ { "id": 1, "id_instituicao": 4, "geojson": { "type": "FeatureCollection", …
Tiago
  • 347
  • 1
  • 3
  • 12
2
votes
1 answer

Parse very large JSON files with dynamic data

I need to parse very large JSON files that are downloaded from a server. These JSON files can contain completely different keys and values. Here are some examples... { "result": "PASS", "items": [ { "name": "John", "age": 33 }, {…
Chris
  • 1,005
  • 1
  • 13
  • 27
2
votes
1 answer

Parse map with dynamic keys with Klaxon

I have the following JSON snippet: { "hd":{ "hdEnabled":true, "defaultStreamQualitySetting":"HD720", "streamQualitySettings":{ "SD":"SD - low quality", "HD720":"Standard HD - 720p", …
Robby Smet
  • 4,649
  • 8
  • 61
  • 104
2
votes
2 answers

Kotlin - How to read JSON string on url

I am new to Kotlin and I find library Klaxon to parse JSON. I can not find how to execute url(http://localhost:8080/items/2), read JSON string and save data to variables and print them to console. CreatedAt and UpdatedAt I do not need to save. JSON…
misolo89
  • 123
  • 1
  • 2
  • 13
2
votes
1 answer

Parse JSON containing nested lists in Kotlin with Klaxon

I'm new to Kotlin and trying to parse list of lists in JSON: data class Root (val lists: List>) val result = Klaxon().parse(""" { "lists": [["red", "green", "blue"]] } """) But I get this runtime exception: Exception in…
David Siegel
  • 1,604
  • 11
  • 13
1
vote
0 answers

Klaxon Error on Converting List to jsonString

in the Kotlin language android development application, I try to use Klaxon to convert my list of objects to JSON string. my code work without error on debugging but after release it has error on JsonArray(queryResult).toJsonString() error is: No…
Farhad
  • 11
  • 1
1
vote
1 answer

Can't parse json in Kotlin

I have a json like…
1
vote
2 answers

Maven install Klaxon

I'm just learning Kotlin and I can't install library Klaxon on my Maven project. GitHub: https://github.com/cbeust/klaxon I copy settings from https://bintray.com/cbeust/maven/klaxon to my pom.xml, but it doesn't work. I try to copy and paste this…
Tatyana .M
  • 33
  • 4
1
vote
2 answers

Klaxon: Expected a name but got LEFT_BRACE

How can I read a "complex" json using Klaxon? I'm trying to use klaxon's stream api as documentation say . I'm using the beginObject method. If I use a json as given in the example everything is fine val objectString = """{ "name" : "Joe", "age" :…
isijara
  • 155
  • 2
  • 9
0
votes
1 answer

Klaxon (JSON) convert whole object including object name

I'm using Klaxon to convert object to JSON objects but it creates an object like so: data class Welcome( val text: String ) results in: { text: "some value" } But i want something like "Welcome"{ text: "Some value" }
0
votes
1 answer

How to get the first image URL from both arrays from my JSON file using Klaxon?

My JSON [ "first_flight": "2010-12-08", "flickr_images": [ "https://i.imgur.com/9fWdwNv.jpg", "https://live.staticflickr.com/8578/16655995541_7817565ea9_k.jpg", …
1
2 3