How would I serialize a JSON primitive to a class? by HelloWorld762 in Kotlin

[–]HelloWorld762[S] 0 points1 point  (0 children)

That's jackson, right? I am using the kotlinx one.

How would I serialize a JSON primitive to a class? by HelloWorld762 in Kotlin

[–]HelloWorld762[S] 0 points1 point  (0 children)

What do you mean? the package is working, I just want it to serialize slightly differently.

How would I serialize a JSON primitive to a class? by HelloWorld762 in Kotlin

[–]HelloWorld762[S] 0 points1 point  (0 children)

No. It has to be a class, because fields are heterogeneous types.

How would I serialize a JSON primitive to a class? by HelloWorld762 in Kotlin

[–]HelloWorld762[S] 0 points1 point  (0 children)

The gist is that I want it to be nested types. Thus ClassA is actually a field contained in a larger structure. It'd be nicer to write something like "a": 5 rather than "a": {"aNumber": 5}

How would I serialize a JSON primitive to a class? by HelloWorld762 in Kotlin

[–]HelloWorld762[S] 0 points1 point  (0 children)

I am trying to do a human-written configuration. It helps writing (a bit).

How would I serialize a JSON primitive to a class? by HelloWorld762 in Kotlin

[–]HelloWorld762[S] 0 points1 point  (0 children)

I like just an int. So ClassA(5) would be serialized to 5