mrosenbladt / yaml-cpp

Automatically exported from code.google.com/p/yaml-cpp
MIT License
0 stars 0 forks source link

Key with colon needs to be quoted (in flow style)? #218

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It seems that a map key that contains a colon needs to be in double quotes, if 
the flow mode is enabled. 

But yaml-cpp (using 0.5.1) doesn't do that.

Example:

  YAML::Emitter out;
  out << YAML::Flow
      << YAML::BeginMap
      << YAML::Key << "my:test" << YAML::Value << 2
      << YAML::EndMap;
  std::cout << out.c_str() << std::endl;

Expected output:
{"my:test": 2}
Current output instead:
{my:test: 2}

The current output does not parse on http://yaml-online-parser.appspot.com/. 
See aso http://pyyaml.org/wiki/YAMLColonInFlowContext 

Or do you think it's a bug in the yaml online parser?

Original issue reported on code.google.com by markus.d...@gmail.com on 9 Sep 2013 at 10:15

GoogleCodeExporter commented 9 years ago
It's legal, according to the YAML spec, to have an unquoted map key with a 
colon:

http://www.yaml.org/spec/1.2/spec.html#id2788859

However, it appears that the authors of pyyaml know about this, and are unsure 
whether to support this or not. 

Original comment by jbe...@gmail.com on 10 Sep 2013 at 4:05