I have a configuration file in hjson format. There are a lot of values and comments in this file.
Simplified file looks like this:
{
# Comments
# comments
Variants: [v1, v2, v3]
# Comments
# comments
Values: { v1: ["asd"]}
# Comments
# comments
Some: [p1, p2]
# Comments
# comments
Name: Champion
# Comments
# comments
Something: [a,b,c]
# etc
# ...
}
I only need to make changes to one array: Variants
(I need to add values there).
The rest remains unchanged.
Now I'm doing this by parsing using serde_hjson (nu_json), working with the config as an object and writing the modified object back to the file as json.
As a result, all comments are lost.
Please tell me how to do what I need without losing the comments in the file.
Comments can be very diverse - each user has their own.
P.S.: this configuration file format was not chosen by me, this is another application.