Richard Gomez
10/02/2021, 12:20 AMJsonObject
to Map<String, Any>
, but am stumped on JsonPrimitive
.
It stores all values as String
, so it doesn't seem possible to get a float/boolean/etc. unless you know its type ahead of time.
Is there a (simpler) way to accomplish this?Richard Gomez
10/02/2021, 12:22 AMgetValue
method which returns the raw type (and stores the raw types in the underlying map).
https://github.com/eclipse-vertx/vert.x/blob/3682ec2b1283b1b30751bef2b816cf04c173fd21/src/main/java/io/vertx/core/json/JsonObject.java#L388-L391ephemient
10/02/2021, 2:22 AM._OrNull
ephemient
10/02/2021, 2:23 AMRichard Gomez
10/03/2021, 12:17 AMorNull
methods together, but that would be imprecise at best.ephemient
10/03/2021, 5:41 PMephemient
10/03/2021, 5:42 PM1.0
is equivalent to 1
ephemient
10/03/2021, 5:46 PMwhen {
jsonPrimitive is JsonNull -> null
jsonPrimitive.isString -> jsonPrimitive.content
else -> jsonPrimitive.content.toBooleanStrictOrNull()
?: jsonPrimitive.content.toBigDecimal()
}
Richard Gomez
10/05/2021, 1:42 PMephemient
10/05/2021, 6:04 PMRichard Gomez
10/05/2021, 9:26 PM