https://github.com/jborean93/PowerShell-Yayaml
A YAML parser and writer that uses an Assembly Load Context on PowerShell 7+
https://github.com/jborean93/PowerShell-Yayaml
Last synced: 4 months ago
JSON representation
A YAML parser and writer that uses an Assembly Load Context on PowerShell 7+
- Host: GitHub
- URL: https://github.com/jborean93/PowerShell-Yayaml
- Owner: jborean93
- License: mit
- Created: 2023-06-15T07:29:46.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-11T03:54:57.000Z (9 months ago)
- Last Synced: 2024-12-01T12:49:02.137Z (4 months ago)
- Language: PowerShell
- Homepage:
- Size: 166 KB
- Stars: 32
- Watchers: 4
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - jborean93/PowerShell-Yayaml - A YAML parser and writer that uses an Assembly Load Context on PowerShell 7+ (PowerShell)
README
# PowerShell-Yayaml
[](https://github.com/jborean93/PowerShell-Yayaml/actions/workflows/ci.yml)
[](https://codecov.io/gh/jborean93/PowerShell-Yayaml)
[](https://www.powershellgallery.com/packages/Yayaml)
[](https://github.com/jborean93/PowerShell-Yayaml/blob/main/LICENSE)Yet Another YAML PowerShell parser and writer.
While there are a few other YAML modules out on the gallery this module includes the following features:+ YAML 1.2 parser and emitter
+ YAML 1.2 JSON parser and emitter
+ Support for custom schemas
+ Finer control over scalar, map, and sequence styles
+ Loads `YamlDotNet` in an Assembly Load Context to avoid DLL hell and cross assembly conflicts (PowerShell 7+ only)
+ Support for emitting comments in `ConvertTo-Yaml` (does not support parsing comments though)There are schemas that support YAML 1.2 (default), 1.2 JSON, 1.1, and failsafe values.
Please note that this module does not support roundtrip representation of the input YAML format.
Support for this may be added in the future if there is demand for it.See [Yayaml index](docs/en-US/Yayaml.md) for more details.
## Requirements
These cmdlets have the following requirements
* PowerShell v5.1 or newer
## Examples
Creating a YAML string is as simple as providing an object to serialize:
```powerhell
$obj = [PSCustomObject]@{
Key = 'value'
Testing = 1, 2, 3
}$obj | ConvertTo-Yaml
```Produces
```yaml
Key: value
Testing:
- 1
- 2
- 3
```Parsing a YAML string to an object:
```powershell
$obj = $yaml | ConvertFrom-Yaml
$obj.Key
$obj.Testing
```The behaviour of these two cmdlets try to follow the `ConvertTo-Json` and `ConvertFrom-Json` cmdlets.
## Installing
The easiest way to install this module is through [PowerShellGet](https://docs.microsoft.com/en-us/powershell/gallery/overview).
You can install this module by running;
```powershell
# Install for only the current user
Install-Module -Name Yayaml -Scope CurrentUser# Install for all users
Install-Module -Name Yayaml -Scope AllUsers
```## Contributing
Contributing is quite easy, fork this repo and submit a pull request with the changes.
To build this module run `.\build.ps1 -Task Build` in PowerShell.
To test a build run `.\build.ps1 -Task Test` in PowerShell.
This script will ensure all dependencies are installed before running the test suite.