yamlkt
yamlkt copied to clipboard
Serialize / Deserialize comments through `Commentable<Any>`
I propose to add a new object instead of using an annotation to decode / encoding comments, so it can support comments for each element?
proposal:
// primitive:
data class CommentableInt(val comment: String, val value: Int)
data class CommentableBoolean(val comment: String, val value: Boolean)
data class CommentableFloat(val comment: String, val value: Float)
...
data class Commentable<T>(val comment: String, val value: T)
yml:
# people's rating
rank: 80
foods: # list declaration
# need a pizza
pizza: true
takeout: true
kotlin:
@Serializable
data class Test(
val rank: CommentableInt,
val foods: List<Commentable<String>>,
val takeout: CommentableBoolean,
)
Also, it seems impossible to serialize comments as objects at present, or do I miss something?
Looks good but this feature requires yamlkt to recognize (the positions of) comments (for now we just ignore all tokens after #).
Look forward to this! I haven not figured out the principle of this library yet, otherwise I am very interested in this PR.