https://kotlinlang.org logo
#serialization
Title
# serialization
n

Nikky

12/24/2018, 9:03 PM
is there any plans for Comments in Json ?
@Comment("what the thing does")
on a filed and
Json(enableComments = true)
to allow parsing and serializing them
🚫 1
s

serebit

12/24/2018, 9:35 PM
the JSON spec doesn’t support comments, so I’d say probably not, but I’m also not JetBrains
o

orangy

12/24/2018, 9:36 PM
Exactly, there are no comments in JSON. There are other formats, like HOCON, for configuration.
1
s

serebit

12/24/2018, 9:39 PM
That being said, unquoted JSON (the JSON5 spec) does support comments.
But adding comment support to only unquoted JSON would be difficult and inconsistent
n

Nikky

12/24/2018, 11:56 PM
hmm then maybe i should see if i can adapt the JSON parser for JSON5
g

gildor

12/25/2018, 7:27 AM
What is your use case? I found hocon as much more suitable and powerful format for configs
n

Nikky

12/25/2018, 10:24 AM
well both configs and serializing data in human readable format (for debugging and version control)
in that case i'd like to have comments along with some data to explain why its there or what added it
g

gildor

12/25/2018, 2:20 PM
In this case hocon is a good choice imo Also supported out of the box by kotlinx.serialization
9 Views