JS pain point: object serialization

I’ve written a few web apps that use Kotlin on both server and browser side. Just about everything gets better with Kotlin, except one thing — I lose the easy serialization of JSON.stringify and JSON.parse when I start using classes, enums, etc.

I guess my wish list has two similar but separate items …

  1. A way to stringify and parse JSON that creates the objects with the correct kotlin types.
  2. Something like java.io.Serializable, but the browser side. It could allow more compact output than JSON, and handle more general object graphs. A server side library could allow passing objects between JS and JVM.

Has anyone had similar problems and found solutions? Are these ideas on the roadmap for Kotlin-Javascript?


1 Like

Perhaps leveraging EDN might be a way forward here?

Does jackson not compile well with kotlinjs?

Isn’t that a Java library? KotlinJS compiles Kotlin code to JS.

  1. JavaScript JSON available from Kotlin, but unfortunately it can’t restore the reference to class.

Are these ideas on the roadmap for Kotlin-Javascript?

Yes, of course.
We already have the issue about JSON serialization/deserialization
And I’ve created the new for general solution

Feel free to vote to get notifications about updates.


We are working on a generic Kotlin Serialization facility. See this thread Kotlin Serialization

1 Like