0

I am very new to yaml file reading and writing , In most of the sites Deserialization and serialization is used for reading and writing and we need to define an object If we want to serialize & deserialize. but I have below file to add a yaml node but the structure not fixed So please help me to add a node in c# with in an yaml file.

I/p File

mescue_path: &mescue_path test/profile
fescue_path: &fescue_path details/prod

mescue_path_server: &mescue_path_server
role: auto
prefix: *mescue_path

fescue_path_server: &fescue_path_server
role: auto
prefix: *fescue_path

westRr: &westRr
  <<: *mescue_path_server
  rack: westRr

eastRr: &eastRr
  <<: *mescue_path_server
  rack: estRr

Mapping:
  mechinerack1: *eastRack
  mechinerack2: *eastRack
  mechinerack3: *eastRack
  mechinerack4: *eastRack

  RRRack1: *westRack
  RRRack2: *WestRack

O/P File:

mescue_path: &mescue_path test/profile
fescue_path: &fescue_path details/prod

mescue_path_server: &mescue_path_server
role: auto
prefix: *mescue_path

fescue_path_server: &fescue_path_server
role: auto
prefix: *fescue_path

westRr: &westRr
  <<: *mescue_path_server
  rack: westRr

*NorthRr: &NorthRr
  <<: *mescue_path_server
  rack: NorthRr*

eastRr: &eastRr
  <<: *fescue_path_server
  rack: estRr

Mapping:
  mechinerack1: *eastRack
  mechinerack2: *eastRack
  mechinerack3: *eastRack
  mechinerack4: *eastRack

  RRRack1: *westRack
  RRRack2: *WestRack
Rand Random
  • 7,300
  • 10
  • 40
  • 88
Sravani
  • 59
  • 5
  • 1
    Does this answer your question? [C# parse and change strings in yaml](https://stackoverflow.com/questions/30492841/c-sharp-parse-and-change-strings-in-yaml) or [How to update a property value in YamlDotNet?](https://stackoverflow.com/questions/68665114/how-to-update-a-property-value-in-yamldotnet) or [How to write data to yaml file](https://stackoverflow.com/questions/62371078/how-to-write-data-to-yaml-file) – Luuk Jan 14 '23 at 13:16

0 Answers0