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

Make YamlNode serializable #641

Open
EdwarDDay opened this issue Nov 16, 2024 · 1 comment · May be fixed by #642
Open

Make YamlNode serializable #641

EdwarDDay opened this issue Nov 16, 2024 · 1 comment · May be fixed by #642

Comments

@EdwarDDay
Copy link
Contributor

Describe the problem you'd like to solve

I would like to deserialize structures, that are partly arbitrary. For example when I want to deserialize the [mustache specification], most of the structure can be properly deserialized with somethling like

@Serializable
data class Specification(
  val overview: String,
  val tests: List<Test>,
)

@Serializable
data class Test(
  val name: String,
  val desc: String,
  val template: String,
  val expected: String,
  val partials: Map<String, String> = emptyMap(),
  val data: YamlNode? = null, // not serializable
)

but the data can't be, because it can be arbitrary nested or even just a primitive value.

Describe the solution you'd like

I would like to have YamlNode as Serializable (similar as done by the kotlinx team for the JsonElement).

Describe alternatives you've considered

I could write it on my own in my project, but I think, this would be really valuable to the library. Another alternative is to read the whole structure as YamlNode and then parse everything on with the node, but that reduces the usability.

Additional context

No response

@charleskorn
Copy link
Owner

This seems reasonable to me, PRs are welcome 🙂

EdwarDDay added a commit to EdwarDDay/kaml that referenced this issue Nov 17, 2024
EdwarDDay added a commit to EdwarDDay/kaml that referenced this issue Nov 17, 2024
@EdwarDDay EdwarDDay linked a pull request Nov 17, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants