yaml-cpp icon indicating copy to clipboard operation
yaml-cpp copied to clipboard

Having issue when reading string parameters

Open ulassbin opened this issue 3 years ago • 2 comments

I am having issues with YAML::Load(file_name) command. String parameters are being converted to something different

For example 
- type: "shelf" 
becomes 
- type: !<!> shelf

I am reading the yaml file as follows:

    YAML::Node config = YAML::LoadFile("/home/ulas/test.yaml");
    YAML::Emitter emit;
    emit << config;
    std::cout << "Initial \n"<<emit.c_str()<<std::endl;`

My yaml file looks like this

item_manager:
  active_items:
    - type: "shelf"
    - type: "drawer"
      params:
        front_drawer:
          color: 1.0                  
    - type: "window"
      params:
        window:
          height: 1.0           

The output becomes

Initial 
item_manager:
  active_items:
    - type: !<!> shelf
    - params:
        front_drawer:
          color: 1.0
      type: !<!> drawer
    - type: !<!> window
      params:
        window:
          height: 1.0

ulassbin avatar Sep 27 '22 12:09 ulassbin

It occurs both in versions 0.5.2-4 and 0.7

ulassbin avatar Sep 27 '22 13:09 ulassbin

This is surprising. I thought this was fixed in Issue #202 (d0250400496b6ac61f672bdad116c36c24383dd8). There's a test added that does:

  Node n(Load("\"test\""));
  out << n;
  ExpectEmit("test");

I guess this is different because it's a map value? Super strange. PRs welcome.

jbeder avatar Sep 28 '22 04:09 jbeder