json-cfg icon indicating copy to clipboard operation
json-cfg copied to clipboard

scape chars for printing colors in json file

Open papillon2k2 opened this issue 3 years ago • 0 comments

I am using json-cfg in a python application and is working ok, but now I need to save in the json some configuration parameters for holding console colors.
For example, in my app I use this to print a string to console in red color: print("\033[0;32mThis is some text in red color")

Now I am trying to get this color values from the config json, but can make it work. I put this in the json file: RedColor: "\033[0;32m"

and then I try to use it like this: print("{}This is some text in red color").format(config.RedColor())

it don't work because is not a valid scape char in json... I have tried to scape it in the json, defining it with double backslash:
RedColor: "\\033[0;32m" but still don't work...

Is there any way to achieve this? Thanks in advance.

papillon2k2 avatar May 29 '21 18:05 papillon2k2