jbeder / yaml-cpp

A YAML parser and emitter in C++
MIT License
4.92k stars 1.78k forks source link

How to check scalar type? (int vs float vs string) #1186

Closed midrare closed 1 year ago

midrare commented 1 year ago

If I have a scalar YAML::Node, but don't know whether it's an int, float, or string, how do I check?

jbeder commented 1 year ago

If you're looking for automatic type detection, just try to parse it as an int or float and see if it works. If you've already specified it with a tag, you can call GetTag() and find out.

(Also, in the future, please ask questions like this on Stack Overfow.)