Type casting - yaml/YAML2 GitHub Wiki
Typically
d: !!float 123 # also a float via explicit data type prefixed by (!!)
e: !!str 123 # a string, disambiguated by explicit type
f: !!str Yes # a string via explicit type
{d: !!float 123 , e: !!str 123 , f: !!str Yes }
What if it's like this?
d: (float) 123 # also a float via explicit data type prefixed by (!!)
e: (str) 123 # a string, disambiguated by explicit type
f: (str) Yes # a string via explicit type
{d: (float) 123 , e: (str) 123 , f: (str) Yes }
custom datatypes could be then like:
d: (!complex) 123+32i
e: (!complex) 123/_32rad
f: (!complex) 23exp84i
g: (!mathEqn) "exp(32x)"
{d: (!complex) 123+32i , e: (!complex) 123/_32rad , f: (!complex) 23exp84i }
If we are willing to disallow "!" in keynames
d!!float: 123 # also a float via explicit data type prefixed by (!!)
e!!str: 123 # a string, disambiguated by explicit type
f!!str: Yes # a string via explicit type
{d!!float: 123 , e!!str: 123 , f!!str: Yes }
Alternatively:
d(float): 123 # also a float via explicit data type prefixed by (!!)
e(str): 123 # a string, disambiguated by explicit type
f(str): Yes # a string via explicit type
{d(float): 123 , e(str): 123 , f(str): Yes }
or:
(float) d: 123 # also a float via explicit data type prefixed by (!!)
(str) e: 123 # a string, disambiguated by explicit type
(str) f: Yes # a string via explicit type
{(float)d: 123 , (str)e: 123 , (str)f: Yes }