How do I represent arbitrary data?
See original GitHub issueSuppose I need to parse JSON and the only sample I’ve seen is { "thing": {} }
.
I’d like to let the type of thing
be a dynamic object value, or even JsonValue
, but I am not sure how to accomplish this.
import com.beust.klaxon.*
data class TopLevel(val thing: Thing)
data class Thing()
val klaxon = Klaxon()
klaxon.parse<TopLevel>("{ \"thing\": {} }")
This doesn’t work because data classes cannot have empty constructors, and I really want to allow TopLevel.thing
to be a dynamic object.
I tried data class TopLevel(val thing: JsonValue)
and it didn’t consider that a suitable constructor for the data.
Any suggestions?
P.S. I tried to join #klaxon on Slack but a @jetbrains
email was required.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
3 Choosing how to represent data
Tables, charts and graphs are all ways of representing data, and they can be used for two broad purposes. The first is to...
Read more >Self-Ref - Introduction to Arbitrary-Sized Data - YouTube
04a - Self Reference. Self-Ref - Introduction to Arbitrary -Sized Data. 9.9K views 9 years ago. Systematic Program Design.
Read more >Arbitrary unit - Wikipedia
In science and technology, an arbitrary unit or procedure defined unit (p.d.u.) is a relative unit of measurement to show the ratio of...
Read more >II Arbitrarily Large Data - How to Design Programs
If a problem statement is about information of arbitrary size, you need a self-referential data definition to represent it.
Read more >Which type do I use to represent an arbitrary blob in Java?
At this point, the code should be agnostic as to what's in the data. What is an appropriate type for the data field?...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This works:
Oh nice find!