Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

scape chars for printing colors in json file #18

Open
papillon2k2 opened this issue May 29, 2021 · 0 comments
Open

scape chars for printing colors in json file #18

papillon2k2 opened this issue May 29, 2021 · 0 comments

Comments

@papillon2k2
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant