Him188 / yamlkt

Multiplatform YAML parser & serializer for kotlinx.serialization written in pure Kotlin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

It is not possible to distinguish primitive types

anti-social opened this issue · comments

I parse yaml to YamlElement and I need a way to differ numbers from strings:

a: 1
b: "1"

In kotlinx.serialization there is an isString property which can be taken into account.

Either there could be special wrappers to all supported data types.

commented

In JSON, unquoted values have their semantics, false means exactly the boolean value false, but in YAML, I think there is no such specification (viz. there are just strings)? You can still have a: foo unquoted.

So it would be nice to have a flag how a scalar node was represented

I's really interesting problem.

What do you think about a recommendation to use a core scheme by default?

https://yaml.org/spec/1.2.2/#103-core-schema

The Core schema is an extension of the JSON schema, allowing for more human-readable presentation of the same types. This is the recommended default schema that YAML processor should use unless instructed otherwise.

All the parsers that I've used in other languages use the core schema, I think.

commented

You are right. I agree we should use the Core schema.