https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
klaxon
  • c

    cedric

    03/07/2018, 9:10 PM
    @nikbucher Fixed in 2.1.10.
    🚀 1
    n
    • 2
    • 9
  • c

    cedric

    04/02/2018, 4:47 PM
    Just came across https://github.com/tomnomnom/gron/ and I was wondering if I shouldn’t provide something similar with Klaxon
    g
    • 2
    • 3
  • a

    Angius

    04/03/2018, 1:27 AM
    A new one took its place, although one not related to Klaxon I believe. https://pastebin.com/3pcHR4zX
    g
    • 2
    • 1
  • t

    Tobias Preuss

    04/11/2018, 9:37 AM
    Hi. I want to try Klaxon from a Java class and noticed that
    new Klaxon().parse<>
    (the
    .parse()
    function) is not available as stated in the docs. How am I supposed to read a JSON string?
    g
    • 2
    • 2
  • c

    cedric

    04/11/2018, 4:44 PM
    Can you include the JSON that Klaxon is trying to parse in the commit above? Hard to diagnose without it
    t
    • 2
    • 1
  • t

    Tobias Preuss

    04/12/2018, 11:58 AM
    I will see if I can create a slimmed down version of the example.
    t
    • 2
    • 1
  • c

    cedric

    05/01/2018, 4:57 PM
    Seems pretty trivial to map with Klaxon
    d
    • 2
    • 4
  • c

    cedric

    05/11/2018, 9:28 PM
    @mingkangpan Should be fixed in 3.0.3
    m
    • 2
    • 7
  • g

    gildor

    07/17/2018, 3:22 PM
    You always can have 2 stages of parsing
    🤔 1
    d
    c
    • 3
    • 15
  • c

    camdenorrb

    08/01/2018, 1:10 AM
    @karelpeetersYes, but you can't do that directly on an object
    k
    • 2
    • 20
  • k

    karelpeeters

    08/02/2018, 9:07 PM
    Is there a way to parse a JsonObject as part of parsing with the object mapper? Something like this:
    data class Foo(val a: JsonObject)
    
    fun main(args: Array<String>) {
    	val json = """{ "a": { "hello": "world" } }"""
    
    	val result = Klaxon().parse<Foo>(json)
    	println(result)
    }
    s
    • 2
    • 3
  • k

    karelpeeters

    08/15/2018, 8:02 AM
    Because a single converter instance can convert multiple different types.
    a
    c
    • 3
    • 12
  • d

    damian

    09/12/2018, 9:23 AM
    Is there a way to handle NaN for float values when parsing the json using klaxon? Currently getting
    Pending exception java.lang.RuntimeException: Unexpected character at position 1023: 'n' (ASCII: 110)'
    s
    k
    • 3
    • 5
  • c

    cedric

    09/18/2018, 3:33 PM
    @dave08 I wonder if there’s anything to gain, where do you see parallelizable units of work? Network access is not really part of Klaxon
    d
    • 2
    • 1
  • j

    jlleitschuh

    10/02/2018, 12:45 AM
    h
    • 2
    • 1
  • c

    cedric

    10/02/2018, 8:16 PM
    Also we should invoke Gradle with the tty option (I think there is one?) so the output on travis is more legible
    h
    • 2
    • 1
  • c

    cedric

    10/10/2018, 7:12 PM
    Try invalid JSON? @arve
    s
    a
    +2
    • 5
    • 41
  • k

    keturn

    10/15/2018, 1:00 AM
    This
    Converter.toJson
    implementation works, but it feels like I'm doing something wrong. Should I be creating additional
    Klaxon()
    instances inside
    toString
    and specifying converters for nested fields there?
    converter.kt
    d
    • 2
    • 10
  • k

    Kylych

    10/18/2018, 5:05 AM
    hi all. Can i use it with retrofit ?
    g
    • 2
    • 3
  • a

    arve

    10/23/2018, 10:34 AM
    data class Thing(val controllers: List<String>) {
                    constructor(controllers: Map<String, Boolean>): this(controllers.keys.toList())
                }
                val json = """ {
                    "controllers": {
                        "a": true,
                        "b": true,
                    }
                }""".trimIndent()
                println(Klaxon().parse<Thing>(json))
    This fails with
    com.beust.klaxon.KlaxonException: Couldn't find a suitable constructor for class Thing to initialize with {controllers=}: java.lang.IllegalArgumentException argument type mismatch
    - but the given alternate constructor should be suitable, no?
    • 1
    • 1
  • c

    cedric

    12/26/2018, 2:39 PM
    @rrader Klaxon doesn't offer any particular support for validation, you can do it any way you want after parsing
    r
    • 2
    • 5
  • d

    dvlwj

    03/12/2019, 9:48 AM
    Hey guys, anyone can help me how to manage my problem? Lets say i need to pull a json in one endpoint that may have thousands item in them. and their format is something like this :
    {
     "records" : [
     {
       "field": value ,
       "field": value
     },
     {
       "field": value,
       "field": value
     },
    // etc until xxx times
    }
    how i can parse the
    records
    ? I know and already can parse the data inside
    records
    , but i m not sure how to get
    records
    . I already try to parse it with this code :
    class Records(val Records:List<Any>? = null)
    but its failed.
    c
    • 2
    • 12
  • c

    czuckie

    04/16/2019, 8:52 PM
    please please please tag releases in github
    g
    • 2
    • 2
  • a

    Andrew Gazelka

    05/10/2019, 1:57 AM
    what is the idiomatic way to turn a JSON string into a prettified String?
    j
    • 2
    • 3
  • c

    cedric

    05/21/2019, 5:38 PM
    What’s the use case?
    a
    • 2
    • 3
  • s

    Spel98

    05/29/2019, 11:24 AM
    HELLO! I have two problems with the JSON function. I have a Molecule object that contains some values ​​... the first problem is with the weight field, of type Float with 3 decimal digits and when I go to create the string Json brings me back a float with a lot the numbers after the comma, in practice the number stops being rounded to 3 digits after the comma. The second problem is with strings containing codes separated by gods + or -. For example the string "301 - 372 - 314 - 410" in json becomes "301\u200b\u2010\u200b372\u2003\u200b314\u200b\u2010\u200b314" and the numbers to the subscript of the formulas as "Hg-⌬-NO₃" become "Hg-⌬-NO\u2083". As if the json didn't use the same charset used for strings in the fields of the object. Does anyone know if there are any parameters to change in the json function? In particular I am taking a list of values ​​from a file separated by some \ to transform them into json ... each line of the file contains the data of a molecule. In practice I am converting an old data saving format to json. But there are problems during the conversion. Note that in the second output the problem with the character - does not occur
    Parsing_Object_to_Json_Problems.kt
    g
    • 2
    • 5
  • k

    K0NN4

    06/18/2019, 11:16 PM
    Hello how would i get "url" out from json like this:``` { "meta": { "status": 200 }, "response": { "hits": [ { "highlights": [], "index": "song", "type": "song", "result": { "url": "https://genius.com/Lucidious-changes-lyrics",```
    c
    • 2
    • 3
  • h

    Hullaballoonatic

    06/27/2019, 1:35 AM
    I'm sorry if this is asked often, and I'm too lazy to look, so tell me to fuck off and search if so: Is Klaxon better than
    kotlinx-serialization
    ? For what reasons should I use one over the other?
    c
    m
    • 3
    • 2
  • c

    cedric

    09/05/2019, 2:13 PM
    Go to search.maven.org and verify that this version is there
    g
    • 2
    • 3
  • j

    Josephwlnorman

    09/05/2019, 2:14 PM
    Ah, interesting it doesn’t appear to be there on an initial search at all
    g
    • 2
    • 2
Powered by Linen
Title
j

Josephwlnorman

09/05/2019, 2:14 PM
Ah, interesting it doesn’t appear to be there on an initial search at all
g

gildor

09/06/2019, 2:44 AM
Use jcenter repositroy instead: https://bintray.com/cbeust/maven/klaxon/5.0.12
j

Josephwlnorman

09/06/2019, 8:51 AM
I saw this shortly after, seems like a good choice. Still need to learn more about Maven!
View count: 3