jbeder / yaml-cpp

A YAML parser and emitter in C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

null keys

oleorhagen opened this issue Β· comments

Hello πŸ‘‹ 😸

I am currently having a problem with null keys in Yaml. AFACT this is a valid Yaml key and value:

null: null

However, the following:

auto y = yaml::Load("null: null");
y["null"] <- non-existent key 'null'

I understand that this is most likely a pilot error, but have not been able to see my mistake. So I just wanted to double check. Is this me, or is this the libraries fault?

Good question. Null does get mapped to a null object by the core schema, but I would have thought you could access it like a string key if you wanted.

Not sure why it's doing that. Happy to accept a PR.

Good question. Null does get mapped to a null object by the core schema, but I would have thought you could access it like a string key if you wanted.

Not sure why it's doing that. Happy to accept a PR.

Sweet - I'll see what I can do πŸ˜„

I compared it with the PyYAML library in python. When the input is null: null, the output is {None: None}. At this time, you can use data[None] to obtain and modify the value, but in this library, null cannot be used as key.

image