Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is !! (double exclamation marks) in YAML?

I have this snippet in a longer YAML:

config:
  operations: !!map

IntelliJ marks the !! as error (expected key-val pair or array item), probably a false positive.
I wanted to understand more about it so I opened YAML specifications but I am still not sure about its use.

Is it used to specify a type or something else?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

On the document you linked, it says that !! is a Secondary Handle or a Core type (Generic Mapping)

Secondary Handle

The secondary tag handle is written as “!!”. This allows using a compact notation for a single “secondary” name space. By default, the prefix associated with this handle is “tag:yaml.org,2002:”.

Further example usages on https://yaml.org/refcard.html is as follows


‘!foo’ : Primary (by convention, means a local "!foo" tag).
‘!!foo’ : Secondary (by convention, means "tag:yaml.org,2002:foo").

Core types: # Default automatic tags.
‘!!map’ : { Hash table, dictionary, mapping }
‘!!seq’ : { List, array, tuple, vector, sequence }
‘!!str’ : Unicode string

More types:
‘!!set’ : {cherries, plums, apples }
‘!!omap’: [ one: 1, two: 2 ]

In your example, it defines that operations is a map that can have other values.
Can see more info here Generic Mapping

Block style: !!map
  Clark : Evans
  Ingy  : döt Net
  Oren  : Ben-Kiki

Flow style: !!map { Clark: Evans, Ingy: döt Net, Oren: Ben-Kiki }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading