YS Binding Libraries
Your existing YAML files are perfectly valid YS files! Using a YS binding library (aka module or package) these files can be loaded into native objects just like a YAML loader would do.
Without a !YS-v0
tag at the top they will load the same as normal.
With that tag, they can be made to take advantage of any of the vast YS
functional capabilities.
YS intends to provide a YS capable YAML loader library (module/package) for every programming language that uses YAML. These libraries are meant to be full replacements for the existing YAML loaders in that language.
Note
YS loaders only return data values that adhere to the JSON data model. While that model is a subset of what can be represented in YAML 1.2, it is what most users of YAML expect. In other words, YS is targeted at YAML's most popular use cases.
Advantages of using YS🔗
YS YAML loaders have major advantages over the existing YAML loaders:
- Same API and capabilities regardless of the programming language.
- New features and bux fixes released to all languages at the same time.
- Highly configurable. Limit YAML and YS capabilities to your exact needs.
- Created by a YAML Specification
creator & maintainer.
Currently Available Libraries🔗
Currently there are working libraries for:
Install these libraries like you would any other library for your language.
You must also install the matching version of the libyamlscript.so
shared
library.
See Installing YS for more info.
You can use these libraries like any other YAML loader. Here's an example usage in Python:
File program.py
:
from yamlscript import YAMLScript
ys = YAMLScript()
input = open('file.ys').read()
data = ys.load(input)
print(data)
File file.ys
:
!YS-v0:
:: # Set values to use in data
name =: "World"
other =: load("other.yaml")
foo:: -[(6 * 7), inc(41), 43.--, (3 .. 9):sum]
bar:: other.stuff:shuffle.take(3)
baz:: "Hello, $name!"
File other.yaml
:
stuff:
- ark
- banana
- cat
- doll
- electron
- flan
- golf ball
Run:
$ python prog.py
{'foo': [42, 42, 42, 42], 'bar': ['cat', 'flan', 'doll'], 'baz': 'Hello, World!'}