Skip to content

QuickYamlLoad

Cinchoo edited this page Jul 1, 2020 · 3 revisions

Loading Yaml file

To load Yaml file, use ChoYamlReader component to parse it. Sample below shows how to load Yaml file (Emp.yaml)

emps:
    - id: 1
      name: Tom

    - id: 2
      name: Mark

Load using iterator

foreach (dynamic e in new ChoYamlReader("Emp.yaml").WithYamlPath("$.emps[*]"))
    Console.WriteLine("Id: " + e.Id + " Name: " + e.Name);

Load using loop

var reader = new ChoYamlReader("Emp.yaml").WithYamlPath("$.emps[*]");
dynamic rec;
 
while ((rec = reader.Read()) != null)
    Console.WriteLine("Id: " + e.Id + " Name: " + e.Name);

Load using POCO object

public class Employee
{
    public int Id { get; set; }
    public string Name { get; set; }
}
foreach (var e in new ChoYamlReader<Employee>("Emp.yaml").WithYamlPath("$.emps[*]"))
    Console.WriteLine("Id: " + e.Id + " Name: " + e.Name);

Please visit below article for detailed walk-through of Yaml reader

Cinchoo ETL - Yaml Reader