Skip to content

emitter loses type info for some strings #1362

Description

@johncoomes

A quoted string value that "looks like" an integer, bool or float value loses the quotes when emitted and so changes type and is no longer a string. The output from pyyaml is also shown for comparison; the values remain quoted.

$ cat lost-quotes.yaml 
["true", "false", "3"]

$ cat lost-quotes.cpp 
#include <cassert>
#include <iostream>

#include "yaml-cpp/yaml.h"

int main(int argc, char** argv)
{
   char input[1024];
   std::cin.getline(input, sizeof(input));
   assert(std::cin.good());
   std::cout << YAML::Load(input) << '\n';
   return 0;
}

# build lost-quotes here ...
$ cat lost-quotes.yaml | build/debug/lost-quotes 
[true, false, 3]

$ cat lost-quotes.yaml | python -c 'import sys; import yaml; print(yaml.safe_load(sys.stdin))'
['true', 'false', '3']

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions