Skip to content

Trying to use an object as a key results in the string '[object Object]' as a key #169

Open
@ExplodingCabbage

Description

@ExplodingCabbage

If I throw the following markup (which I believe is not valid YAML, though I'm not even remotely an expert) into the online YAML parser at http://yaml-online-parser.appspot.com/ ...

{{"foo": "bar"}: {"qux": "baz"}}

... then I get:

ERROR:

while constructing a mapping
in "", line 1, column 1:
{{"foo": "bar"}: {"bla": "bla"}}
^
found unacceptable key (dict objects are unhashable)
in "", line 1, column 2:
{{"foo": "bar"}: {"bla": "bla"}}

If I throw it into yaml.safeLoad, on the other hand, I don't get an error. Instead I get this:

> yaml.safeLoad('{{"foo": "bar"}: {"bla": "bla"}}')
{ '[object Object]': { bla: 'bla' } }

Whatever the correct behaviour here is (and I defer that question to those more knowledgable than me), this is plainly not it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions