# JS pain point: object serialization

**URL:** <https://discuss.kotlinlang.org/t/js-pain-point-object-serialization/1892>\
**Category:** Uncategorized\
**Created:** [July 31, 2016, 6:32pm UTC](https://discuss.kotlinlang.org/t/js-pain-point-object-serialization/1892 "2016-07-31T18:32:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rnikander](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/rnikander/32/6881_2.png) [@rnikander](https://discuss.kotlinlang.org/u/rnikander)\
**Post date:** [July 31, 2016, 6:32pm UTC](https://discuss.kotlinlang.org/t/js-pain-point-object-serialization/1892/1 "2016-07-31T18:32:51Z")

</div>

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?

Rob

---

<div class="post-metadata">

**Author:** ![kni](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/kni/32/1879_2.png) [@kni](https://discuss.kotlinlang.org/u/kni)\
**Post date:** [August 3, 2016, 11:02am UTC](https://discuss.kotlinlang.org/t/js-pain-point-object-serialization/1892/2 "2016-08-03T11:02:55Z")

</div>

Perhaps leveraging EDN might be a way forward here?

> **[GitHub - edn-format/edn: Extensible Data Notation](https://github.com/edn-format/edn)**
>
> Extensible Data Notation. Contribute to edn-format/edn development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![jpliska](https://avatars.discourse-cdn.com/v4/letter/j/e274bd/32.png) [@jpliska](https://discuss.kotlinlang.org/u/jpliska)\
**Post date:** [August 11, 2016, 10:57am UTC](https://discuss.kotlinlang.org/t/js-pain-point-object-serialization/1892/3 "2016-08-11T10:57:38Z")

</div>

Does jackson not compile well with kotlinjs?

---

<div class="post-metadata">

**Author:** ![rnikander](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/rnikander/32/6881_2.png) [@rnikander](https://discuss.kotlinlang.org/u/rnikander)\
**Post date:** [August 11, 2016, 3:34pm UTC](https://discuss.kotlinlang.org/t/js-pain-point-object-serialization/1892/4 "2016-08-11T15:34:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bashor](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/bashor/32/1431_2.png) [@bashor](https://discuss.kotlinlang.org/u/bashor)\
**Post date:** [August 11, 2016, 6:01pm UTC](https://discuss.kotlinlang.org/t/js-pain-point-object-serialization/1892/5 "2016-08-11T18:01:54Z")

</div>

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](https://youtrack.jetbrains.com/issue/KT-7939)  
And I’ve created [the new for general solution](https://youtrack.jetbrains.com/issue/KT-13428)

Feel free to vote to get notifications about updates.

---

<div class="post-metadata">

**Author:** ![elizarov](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/elizarov/32/2164_2.png) [@elizarov](https://discuss.kotlinlang.org/u/elizarov)\
**Post date:** [October 25, 2016, 12:30pm UTC](https://discuss.kotlinlang.org/t/js-pain-point-object-serialization/1892/6 "2016-10-25T12:30:47Z")

</div>

We are working on a generic Kotlin Serialization facility. See this thread [Kotlin Serialization](https://discuss.kotlinlang.org/t/kotlin-serialization/2063)
