YamlMap 1.5.0-RC05
dotnet add package YamlMap --version 1.5.0-RC05
NuGet\Install-Package YamlMap -Version 1.5.0-RC05
<PackageReference Include="YamlMap" Version="1.5.0-RC05" />
<PackageVersion Include="YamlMap" Version="1.5.0-RC05" />
<PackageReference Include="YamlMap" />
paket add YamlMap --version 1.5.0-RC05
#r "nuget: YamlMap, 1.5.0-RC05"
#:package YamlMap@1.5.0-RC05
#addin nuget:?package=YamlMap&version=1.5.0-RC05&prerelease
#tool nuget:?package=YamlMap&version=1.5.0-RC05&prerelease
YamlMap
A .NET Yaml Parser.
Map Yaml to .NET objects and vice versa.
Usage
Deserialize a yaml string to an object
// Read a file using a YamlFileReader
var reader = new YamlFileReader();
var item = reader.Read<Item>(filepath);
// or
// Read a string using the YamlReader
var reader = new YamlReader();
var item = reader.Read<Item>(yaml);
// or
// Read a string using the static Serializer
var item = Serializer.Deserialize<Item>(yaml);
Serialize an object to a yaml string
// Write a file using a YamFilelWriter
var writer = new YamlFileWriter();
writer.Write(filepath, item);
// or
// Serialize an object to a string using a YamlWriter
var writer = new YamlWriter();
writer.Write(item);
// or
// serialize an object to string using the static Serializer
var yml = Serializer.Serialize(item);
Implemented serialization features
- Reading YAML strings to Tokens
- Deserializing YAML string to a POCO
- Writing Tokens to YAML
- Serializing POCO to YAML
Implemented YAML features
Comments
# This is a comment
Properties
Property: Value
Objects
User:
name: John Smith
age: 33
Lists
Movies:
- Casablanca
- Spellbound
- Notorious
Inline Lists
Movies: [Casablanca, Spellbound, Notorious]
Multiline Lists
Movies: [Casablanca,
Spellbound, Notorious]
Quotations
Movies: "Casablanca, Spellbound, Notorious"
Drive: 'c: is a drive'
Block statements (multiline strings)
Text: |
There was a young fellow of Warwick
Who had reason for feeling euphoric
For he could, by election
Have triune erection
Ionic, Corinthian, and Doric
WrappedText: >
Wrapped text
will be folded
into a single
paragraph
Blank lines denote
paragraph breaks
Pitfalls with Plain flow scalars:
- Colons (:) can be contained in a string, but are not allowed before a space or newline
Not yet implemented YAML Features
Blocks
---
Inline Objects
User: {name: John Smith, age: 33}
Block statements with strip or keep newlines at end
Text: |+
There was a young fellow of Warwick
Text: |-
There was a young fellow of Warwick
WrappedText: >+
Wrapped text
WrappedText: >-
Wrapped text
Best practice
Deserializng yaml to a Object
To deserialize a Yaml to a object, it is best to have a parameterless constructor.
If a object needs to have a constructor with parameters, the parameter names have to be the same as the properties that they are mapped to.
Else YamlMap will not be able to map the correct values to the parameters.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.