Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialize / Deserialize comments through Commentable<Any> #35

Open
chachako opened this issue Sep 29, 2021 · 2 comments
Open

Serialize / Deserialize comments through Commentable<Any> #35

chachako opened this issue Sep 29, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@chachako
Copy link

chachako commented Sep 29, 2021

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?

@Him188
Copy link
Owner

Him188 commented Sep 29, 2021

Looks good but this feature requires yamlkt to recognize (the positions of) comments (for now we just ignore all tokens after #).

@Him188 Him188 added the enhancement New feature or request label Sep 29, 2021
@chachako
Copy link
Author

Look forward to this! I haven not figured out the principle of this library yet, otherwise I am very interested in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants