How can I update a specific value on a custom configuration file?
Question: Assuming I have a configuration txt file with this content:

    
    
    {"Mode":"Classic","Encoding":"UTF-8","Colors":3,"Blue":80,"Red":90,"Green":160,"Shortcuts":[],"protocol":"2.1"}
    

How can i change a specific value like `"Red":90` to `"Red":110` in the file
without changing its original format?

I have tried with configparser and configobj but as they are designed for .INI
files I couldn't figure out how to make it work with this custom config file.
I also tried splitting the lines searching for the keywords witch values I
wanted to change but couldn't save the file the same way it was before. Any
ideas how to solve this? (I'm very new in Python)


Answer: this looks like json so you could:

    
    
    import json
    
    obj  = json.load(open("/path/to/jsonfile","r"))
    obj["Blue"] = 10
    json.dump(obj,open("/path/to/mynewfile","w"))
    

but be aware that a json dict does not have an order. So the order of the
elements is not guaranteed (and normally it's not needed) json lists have an
order though.

