# YAML Test Matrix

--- &test-FH7J
  Title: Tags on Empty Scalars
  Tags: [ scalar, tag ]

YAML

- !!str
-
  !!null : a
  b: !!str
- !!str : !!null

Expected Events

+STR
+DOC
+SEQ
=VAL <tag:yaml.org,2002:str> :
+MAP
=VAL <tag:yaml.org,2002:null> :
=VAL :a
=VAL :b
=VAL <tag:yaml.org,2002:str> :
-MAP
+MAP
=VAL <tag:yaml.org,2002:str> :
=VAL <tag:yaml.org,2002:null> :
-MAP
-SEQ
-DOC
-STR

Expected JSON



c-libfyaml-event

 ok

c-libyaml-event

 ok

cpp-rapidyaml-event

 ok

cpp-yamlcpp-event

 ok

dotnet-yamldotnet-event

 ok

hs-hsyaml-event

 ok

js-yaml-event

 ok

nim-nimyaml-event

 ok

perl-pp-event

 ok

perl-refparser-event

 ok

py-pyyaml-event

 ok

py-ruamel-event

 ok

rust-yamlrust-event

 ok

perl-syck-perl

 error
Syck parser (line 3, column 10): syntax error at /perl5/lib/perl5/x86_64-linux-thread-multi/YAML/Syck.pm line 60, <> line 1.

c-libfyaml-json

 na
[
  "",
  {
    "": "a",
    "b": ""
  },
  {
    "": null
  }
]

dotnet-yamldotnet-json

 na
Unhandled exception. YamlDotNet.Core.YamlException: (Line: 3, Col: 3, Idx: 12) - (Line: 3, Col: 11, Idx: 20): Encountered an unresolved tag 'tag:yaml.org,2002:null'
   at YamlDotNet.Serialization.NodeTypeResolvers.PreventUnknownTagsNodeTypeResolver.YamlDotNet.Serialization.INodeTypeResolver.Resolve(NodeEvent nodeEvent, Type& currentType)
   at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.GetTypeFromEvent(NodeEvent nodeEvent, Type currentType)
   at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
   at YamlDotNet.Serialization.ValueDeserializers.AliasValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
   at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.<>c__DisplayClass3_0.<DeserializeValue>b__0(IParser r, Type t)
   at YamlDotNet.Serialization.NodeDeserializers.DictionaryNodeDeserializer.DeserializeHelper(Type tKey, Type tValue, IParser parser, Func`3 nestedObjectDeserializer, IDictionary result)
   at YamlDotNet.Serialization.NodeDeserializers.DictionaryNodeDeserializer.YamlDotNet.Serialization.INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func`3 nestedObjectDeserializer, Object& value)
   at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
   at YamlDotNet.Serialization.ValueDeserializers.AliasValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
   at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.<>c__DisplayClass3_0.<DeserializeValue>b__0(IParser r, Type t)
   at YamlDotNet.Serialization.NodeDeserializers.CollectionNodeDeserializer.DeserializeHelper(Type tItem, IParser parser, Func`3 nestedObjectDeserializer, IList result, Boolean canUpdate)
   at YamlDotNet.Serialization.NodeDeserializers.CollectionNodeDeserializer.YamlDotNet.Serialization.INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func`3 nestedObjectDeserializer, Object& value)
   at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
   at YamlDotNet.Serialization.ValueDeserializers.AliasValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
   at YamlDotNet.Serialization.Deserializer.Deserialize(IParser parser, Type type)
   at YamlDotNet.Serialization.Deserializer.Deserialize(TextReader input, Type type)
   at YamlDotNet.Serialization.Deserializer.Deserialize(TextReader input)
   at Program.Main(String[] commandLineArguments)
Aborted (core dumped)

go-yaml-json

 na
panic: interface conversion: interface {} is nil, not string

goroutine 1 [running]:
main.convert({0x4f8e60, 0xc000064660})
	/buildutils/go-yaml-json.go:17 +0x1c7
main.convert({0x4f32c0, 0xc00000c0d8})
	/buildutils/go-yaml-json.go:22 +0x1ec
main.main()
	/buildutils/go-yaml-json.go:45 +0x2a5

hs-hsyaml-json

 na
["",{"":"a","b":""},{"":null}]

hs-reference-yeast

 na
Line  Col Char Byte Token|Content
   1    0    0    0 +DOC |
   1    0    0    0 +NODE|
   1    0    0    0 +SEQ |
   1    0    0    0 =SYNX|-
   1    1    1    1 =WSPC|.
   1    2    2    2 +NODE|
   1    2    2    2 +PROP|
   1    2    2    2 +TAG |
   1    2    2    2 +HAND|
   1    2    2    2 =SYNX|!
   1    3    3    3 =SYNX|!
   1    4    4    4 -HAND|
   1    4    4    4 =META|str
   1    7    7    7 -TAG |
   1    7    7    7 -PROP|
   1    7    7    7 +VAL |
   1    7    7    7 -VAL |
   1    7    7    7 -NODE|
   1    7    7    7 =EOL |\x0a
   2    0    8    8 =SYNX|-
   2    1    9    9 +NODE|
   2    1    9    9 =EOL |\x0a
   3    0   10   10 +MAP |
   3    0   10   10 =DENT|..
   3    2   12   12 +PAIR|
   3    2   12   12 +NODE|
   3    2   12   12 +PROP|
   3    2   12   12 +TAG |
   3    2   12   12 +HAND|
   3    2   12   12 =SYNX|!
   3    3   13   13 =SYNX|!
   3    4   14   14 -HAND|
   3    4   14   14 =META|null
   3    8   18   18 -TAG |
   3    8   18   18 -PROP|
   3    8   18   18 +VAL |
   3    8   18   18 -VAL |
   3    8   18   18 -NODE|
   3    8   18   18 =WSPC|.
   3    9   19   19 =SYNX|:
   3   10   20   20 =WSPC|.
   3   11   21   21 +NODE|
   3   11   21   21 +VAL |
   3   11   21   21 =TEXT|a
   3   12   22   22 -VAL |
   3   12   22   22 -NODE|
   3   12   22   22 =EOL |\x0a
   4    0   23   23 -PAIR|
   4    0   23   23 =DENT|..
   4    2   25   25 +PAIR|
   4    2   25   25 +NODE|
   4    2   25   25 +VAL |
   4    2   25   25 =TEXT|b
   4    3   26   26 -VAL |
   4    3   26   26 -NODE|
   4    3   26   26 =SYNX|:
   4    4   27   27 =WSPC|.
   4    5   28   28 +NODE|
   4    5   28   28 +PROP|
   4    5   28   28 +TAG |
   4    5   28   28 +HAND|
   4    5   28   28 =SYNX|!
   4    6   29   29 =SYNX|!
   4    7   30   30 -HAND|
   4    7   30   30 =META|str
   4   10   33   33 -TAG |
   4   10   33   33 -PROP|
   4   10   33   33 +VAL |
   4   10   33   33 -VAL |
   4   10   33   33 -NODE|
   4   10   33   33 =EOL |\x0a
   5    0   34   34 -PAIR|
   5    0   34   34 -MAP |
   5    0   34   34 -NODE|
   5    0   34   34 =SYNX|-
   5    1   35   35 =DENT|.
   5    2   36   36 +NODE|
   5    2   36   36 +MAP |
   5    2   36   36 +PAIR|
   5    2   36   36 +NODE|
   5    2   36   36 +PROP|
   5    2   36   36 +TAG |
   5    2   36   36 +HAND|
   5    2   36   36 =SYNX|!
   5    3   37   37 =SYNX|!
   5    4   38   38 -HAND|
   5    4   38   38 =META|str
   5    7   41   41 -TAG |
   5    7   41   41 -PROP|
   5    7   41   41 +VAL |
   5    7   41   41 -VAL |
   5    7   41   41 -NODE|
   5    7   41   41 =WSPC|.
   5    8   42   42 =SYNX|:
   5    9   43   43 =WSPC|.
   5   10   44   44 +NODE|
   5   10   44   44 +PROP|
   5   10   44   44 +TAG |
   5   10   44   44 +HAND|
   5   10   44   44 =SYNX|!
   5   11   45   45 =SYNX|!
   5   12   46   46 -HAND|
   5   12   46   46 =META|null
   5   16   50   50 -TAG |
   5   16   50   50 -PROP|
   5   16   50   50 +VAL |
   5   16   50   50 -VAL |
   5   16   50   50 -NODE|
   5   16   50   50 =EOL |\x0a
   6    0   51   51 -PAIR|
   6    0   51   51 -MAP |
   6    0   51   51 -NODE|
   6    0   51   51 -SEQ |
   6    0   51   51 -NODE|
   6    0   51   51 -DOC |

js-jsyaml-json

 na
/node/node_modules/js-yaml/lib/loader.js:187
  throw generateError(state, message);
  ^
YAMLException: bad indentation of a sequence entry (3:10)

 1 | - !!str
 2 | -
 3 |   !!null : a
--------------^
 4 |   b: !!str
 5 | - !!str : !!null
    at generateError (/node/node_modules/js-yaml/lib/loader.js:183:10)
    at throwError (/node/node_modules/js-yaml/lib/loader.js:187:9)
    at readBlockSequence (/node/node_modules/js-yaml/lib/loader.js:1015:7)
    at composeNode (/node/node_modules/js-yaml/lib/loader.js:1440:12)
    at readDocument (/node/node_modules/js-yaml/lib/loader.js:1625:3)
    at loadDocuments (/node/node_modules/js-yaml/lib/loader.js:1688:5)
    at Object.loadAll (/node/node_modules/js-yaml/lib/loader.js:1701:19)
    at Object.<anonymous> (/yaml/bin/js-jsyaml-json:7:13)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10) {
  reason: 'bad indentation of a sequence entry',
  mark: {
    name: null,
    buffer: '- !!str\n-\n  !!null : a\n  b: !!str\n- !!str : !!null\n',
    position: 19,
    line: 2,
    column: 9,
    snippet: ' 1 | - !!str\n' +
      ' 2 | -\n' +
      ' 3 |   !!null : a\n' +
      '--------------^\n' +
      ' 4 |   b: !!str\n' +
      ' 5 | - !!str : !!null'
  }
}

Node.js v20.13.1

js-yaml-json

 na
[
  "",
  {
    "": "a",
    "b": ""
  },
  {
    "": null
  }
]

lua-lyaml-json

 na
luajit: /yaml/bin/lua-lyaml-json:8: Cannot serialise table: table key must be a number or string
stack traceback:
	[C]: in function 'encode'
	/yaml/bin/lua-lyaml-json:8: in main chunk
	[C]: at 0x55fbeedf6ed0

perl-pp-json

 na
[
   "",
   {
      "" : "a",
      "b" : ""
   },
   {
      "" : null
   }
]

perl-pp-perl

 na
[
  '',
  {
    '' => 'a',
    'b' => ''
  },
  {
    '' => undef
  }
]

perl-pplibyaml-json

 na
[
   "",
   {
      "" : "a",
      "b" : ""
   },
   {
      "" : null
   }
]

perl-pplibyaml-perl

 na
[
  '',
  {
    '' => 'a',
    'b' => ''
  },
  {
    '' => undef
  }
]

perl-syck-json

 na
Syck parser (line 3, column 10): syntax error at /perl5/lib/perl5/x86_64-linux-thread-multi/YAML/Syck.pm line 60, <> line 1.

perl-tiny-json

 na
YAML::Tiny does not support a feature in line '!!str' at /yaml/bin/perl-tiny-json line 12.

perl-xs-json

 na
[
   "",
   {
      "" : "a",
      "b" : ""
   },
   {
      "" : null
   }
]
Use of uninitialized value in subroutine entry at /yaml/bin/perl-xs-json line 14, <> line 1.

perl-xs-perl

 na
[
  '',
  {
    '' => 'a',
    'b' => ''
  },
  {
    '' => undef
  }
]
Use of uninitialized value in subroutine entry at /yaml/bin/perl-xs-perl line 16, <> line 1.

perl-yaml-json

 na
[
   null,
   {
      "" : "a",
      "b" : null
   },
   ": !!null"
]

perl-yaml-perl

 na
[
  undef,
  {
    '' => 'a',
    'b' => undef
  },
  ': !!null'
]

py-pyyaml-json

 na
Error json.dumps: <class 'TypeError'>
Traceback (most recent call last):
  File "/yaml/bin/py-pyyaml-json", line 21, in <module>
    print(json.dumps(doc, sort_keys=True, skipkeys=True, indent=2))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
          ^^^^^^^^^^^
  File "/usr/lib/python3.12/json/encoder.py", line 202, in encode
    chunks = list(chunks)
             ^^^^^^^^^^^^
  File "/usr/lib/python3.12/json/encoder.py", line 430, in _iterencode
    yield from _iterencode_list(o, _current_indent_level)
  File "/usr/lib/python3.12/json/encoder.py", line 326, in _iterencode_list
    yield from chunks
  File "/usr/lib/python3.12/json/encoder.py", line 354, in _iterencode_dict
    items = sorted(dct.items())
            ^^^^^^^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'str' and 'NoneType'

py-pyyaml-py

 na
['', {None: 'a', 'b': ''}, {'': None}]

py-ruamel-json

 na
Error json.dumps: <class 'TypeError'>
Traceback (most recent call last):
  File "/yaml/bin/py-ruamel-json", line 23, in <module>
    print(json.dumps(doc, sort_keys=True, skipkeys=True, indent=2))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
          ^^^^^^^^^^^
  File "/usr/lib/python3.12/json/encoder.py", line 202, in encode
    chunks = list(chunks)
             ^^^^^^^^^^^^
  File "/usr/lib/python3.12/json/encoder.py", line 430, in _iterencode
    yield from _iterencode_list(o, _current_indent_level)
  File "/usr/lib/python3.12/json/encoder.py", line 326, in _iterencode_list
    yield from chunks
  File "/usr/lib/python3.12/json/encoder.py", line 354, in _iterencode_dict
    items = sorted(dct.items())
            ^^^^^^^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'str' and 'NoneType'

py-ruamel-py

 na
['', {None: 'a', 'b': ''}, {'': None}]

ruby-psych-json

 na
["",{"":"a","b":""},{"":null}]

perl-tiny-perl

 ni
YAML::Tiny does not support a feature in line '!!str' at /yaml/bin/perl-tiny-perl line 15.