Menu

#2 Spaces in key should be allowed

open
nobody
None
5
2009-09-01
2009-09-01
Carl Fyffe
No

The parser does not allow spaces in the key

foo bar: value

is considered invalid. I have updated PlainYamlParser to allow spaces.

Discussion

  • Carl Fyffe

    Carl Fyffe - 2009-09-01

    allow spaces

     
  • Carl Fyffe

    Carl Fyffe - 2009-09-01

    Here's a test for the Validator:

    public void testMappingWithStringInKey() throws Exception {
    _schema = "" +
    "type: map\n" +
    "mapping:\n" +
    " 'foo bar':\n" +
    " type: str\n";
    _valid = "'foo bar': value";
    _invalid = "foobar: value";
    _error = ":key_undefined : (line 1)[/foobar] key 'foobar:' is undefined.\n";
    doTest();

    _valid = "foo bar: value";
    doTest();
    }

    and here's a test for the parser:

    public void testSpacesWorkInKeys() throws Exception {
    _input = "foo bar: value";
    _expected = "{\"foo bar\"=>\"value\"}";
    doTest();
    }

     

Log in to post a comment.

MongoDB Logo MongoDB