Coder Social home page Coder Social logo

aaubry / yamldotnet.sandbox Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 7.09 MB

A sandbox repository for testing the CI pipeline of YamlDotNet. Please do not open issues on this repository.

License: MIT License

C# 99.53% Shell 0.07% Batchfile 0.01% PowerShell 0.20% Dockerfile 0.18% Perl 0.01%

yamldotnet.sandbox's Introduction

YamlDotNet

Travis Appveyor NuGet
Travis CI Build status NuGet

YamlDotNet is a YAML library for netstandard and other .NET runtimes.

YamlDotNet provides low level parsing and emitting of YAML as well as a high level object model similar to XmlDocument. A serialization library is also included that allows to read and write objects from and to YAML streams.

YamlDotNet's conformance with YAML specifications:

YAML Spec YDN Parser YDN Emitter
v1.1
v1.2

What is YAML?

YAML, which stands for "YAML Ain't Markup Language", is described as "a human friendly data serialization standard for all programming languages". Like XML, it allows to represent about any kind of data in a portable, platform-independent format. Unlike XML, it is "human friendly", which means that it is easy for a human to read or produce a valid YAML document.

The YamlDotNet library

The library has now been successfully used in multiple projects and is considered fairly stable. It is compatible with the following runtimes:

  • netstandard 2.1
  • netstandard 1.3
  • .NET Framework 4.5
  • Unity Subset v3.5

The following runtimes are also supported, with a few features missing:

  • .NET Framework 3.5
  • .NET Framework 2.0

The library is compatible with mono's Ahead-of-Time compilation (AOT), and should work correctly on platforms that depend on it, such as Unity.

Quick start

Here are some quick samples to get you started which can be viewed in this fiddle.

Serialization from an object to a string

using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
...

 var person = new Person
{
    Name = "Abe Lincoln",
    Age = 25,
    HeightInInches = 6f + 4f / 12f,
    Addresses = new Dictionary<string, Address>{
        { "home", new  Address() {
                Street = "2720  Sundown Lane",
                City = "Kentucketsville",
                State = "Calousiyorkida",
                Zip = "99978",
            }},
        { "work", new  Address() {
                Street = "1600 Pennsylvania Avenue NW",
                City = "Washington",
                State = "District of Columbia",
                Zip = "20500",
            }},
    }
};

var serializer = new SerializerBuilder()
    .WithNamingConvention(CamelCaseNamingConvention.Instance)
    .Build();
var yaml = serializer.Serialize(person);
System.Console.WriteLine(yaml);
// Output: 
// name: Abe Lincoln
// age: 25
// heightInInches: 6.3333334922790527
// addresses:
//   home:
//     street: 2720  Sundown Lane
//     city: Kentucketsville
//     state: Calousiyorkida
//     zip: 99978
//   work:
//     street: 1600 Pennsylvania Avenue NW
//     city: Washington
//     state: District of Columbia
//     zip: 20500

Deserialization from a string to an object

using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
...

var yml = @"
name: George Washington
age: 89
height_in_inches: 5.75
addresses:
  home:
    street: 400 Mockingbird Lane
    city: Louaryland
    state: Hawidaho
    zip: 99970
";

var deserializer = new DeserializerBuilder()
    .WithNamingConvention(UnderscoredNamingConvention.Instance)  // see height_in_inches in sample yml 
    .Build();

//yml contains a string containing your YAML
var p = deserializer.Deserialize<Person>(yml);
var h = p.Addresses["home"];
System.Console.WriteLine($"{p.Name} is {p.Age} years old and lives at {h.Street} in {h.City}, {h.State}.");
// Output:
// George Washington is 89 years old and lives at 400 Mockingbird Lane in Louaryland, Hawidaho.

More information

More information can be found in the project's wiki.

Installing

Just install the YamlDotNet NuGet package:

PM> Install-Package YamlDotNet

If you do not want to use NuGet, you can download binaries here.

YamlDotNet is also available on the Unity Asset Store.

Contributing

Please read CONTRIBUTING.md for guidelines.

Release notes

Release notes for the latest version

yamldotnet.sandbox's People

Contributors

210342 avatar aaubry avatar am11 avatar antoine-aubry avatar asmichi avatar atruskie avatar conniey avatar damageboy avatar daniel15 avatar dol-leodagan avatar grapefrukt avatar grofit avatar himura2la avatar jeffman avatar johshoff avatar justinyoo avatar leon-m avatar matthewrwilton avatar mattmiller85 avatar mlaily avatar nbarbettini avatar nickbabcock avatar pensono avatar roji avatar sourcenouveau avatar steinbitglis avatar sungam3r avatar vcipher avatar vwxyzh avatar wattsm avatar

Watchers

 avatar  avatar  avatar

yamldotnet.sandbox's Issues

Another test

Describe the bug
A clear and concise description of what the bug is. Please explain what you observe and what you expected to happen instead. If there is an exception, include its message and stack trace.

To Reproduce
Try to add the steps needed to reproduce the problem. Feel free to open a pull request with a failing test if that makes sense. Otherwise, at least provide some code and / or YAML that reproduce the issue.

[1, 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.