-
Notifications
You must be signed in to change notification settings - Fork 624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JsonElement should expose the original value #1799
Comments
It should be noted that the extension functions defined on |
Well, there are when(element) {
is JsonObject -> ...
is JsonArray -> ...
is JsonNull -> ....
else -> ...
} Does it solve your problem? Regarding type information in |
No, because |
Then it's a duplicate of #1298, I answered you there |
What is your use-case and why do you need this feature?
I'm working with raw schema-less JSON data, i.e., I need to use the plain
JsonElement
class. The use case involves accessing the underlying value wrapped byJsonElement
.Currently this is awkward and inefficient, because the
JsonElement
only exposes the underlying value in the form of aString
. This requires repeated re-parsing of the string (plus incorporating theisString
information) to get e.g. actual boolean/number values etc.Describe the solution you'd like
I'm completely new to Kotlin, so I lack the skills to draft an ideal solution.
What I would have expected from a user perspective is that the
JsonElement
is modeled like JSON data is modeled in other languages, i.e., with explicit (sealed) subclasses forJsonString
,JsonNumber
,JsonBoolean
,JsonNull
,JsonArray
,JsonObject
, where all e.g.x.value
of the appropriate type.The text was updated successfully, but these errors were encountered: