Skip to content

Conversation

@holodorum
Copy link
Collaborator

@holodorum holodorum commented Apr 2, 2025

In the same vein as the work done in "YAML as a Kson compilation target" we now added JSON as a compilation target too.

The heart of the work is done in 34dd09e, with 625e66e performing a preparatory refactor

In working towards adding Json as a compile target, which _never_
allows comments, it highlighted that `preserveComments` isn't really a
"Core" configuration, but rather a CompileTarget-specific choice

So: refactor to better reflect this and be ready for future
CompileTargets
Introduce a new compilation target for JSON, allowing Kson to parse and
compile to JSON format.
Since Json does not support comments, we can set `preserveComments`
to `false` for all instances of its CompileTarget config
Unlike for Yaml, where no official/blessed cross-platform parser exists
that I know of, Kotlinx.serialization provides a cross-platform JSON
parser. So, we don't need to restrict our tests' Json validation to just
our JVM tests like we do with Yaml.

This should just run redundant checks on each platform, but a good
general goal is to write multiplatform code whenever possible, and
plus: I'm very curious if this will ever fail some day exposing some
surprising difference in Json parsing across our supported platforms.
@dmarcotte
Copy link
Contributor

This is fantastic, @holodorum, thanks so much. Very excited to have this in.

@dmarcotte dmarcotte merged commit 4b7961b into kson-org:main Apr 6, 2025
1 check passed
@dmarcotte dmarcotte deleted the json-transpiler branch April 6, 2025 04:34
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 this pull request may close these issues.

2 participants