'how to stop yaml parse/stringify removing !Equals and !Ref

In my node/typescript application, I have a yaml file in string format that I am modifying, so I am first using the parse function from the yaml library, making the edits and then turning it back to a string with stringify from the same yaml library. In my original yaml there exists the following line (the quotation marks and + are just due to the fact that it's in string format):

'IsFlagEnabled: !Equals [!Ref FlagEnabled, true]' + 

However, after I use parse, make changes to the object (I'm just adding new properties and my changes don't have anything to do with the above line) and then use stringify, the above line then gets changed to:

'  IsFlagEnabled:\n' +

    '    - FlagEnabled\n' +

    '    - true\n' + 

I do not wish for this change to happen - is there any way I can make sure the 'IsFlagEnabled: !Equals [!Ref FlagEnabled, true]' + line is unchanged? If not is there an alternative method using parse, modifying the JSON and using stringify again to make sure that I am able to make my desired changes to the yaml, without changing other parts involving !Equals and !Ref?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source