Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional plain JSON result #197

Open
hingehe opened this issue Jul 19, 2022 · 3 comments
Open

Optional plain JSON result #197

hingehe opened this issue Jul 19, 2022 · 3 comments

Comments

@hingehe
Copy link

hingehe commented Jul 19, 2022

Summary

I've had a hard time to read the output of jwt in my programming tool in spite of the -j option, because in error-case it doesn't return plain json as expected:
�[0m�[1m�[31mThe JWT provided is invalid because Error(Base64(InvalidByte(85, 61)))
{
"header": {
"typ": "JWT",
"alg": "ES256",
[...]
Especially the weird color-information in the error should be deactivatable by a new option (like --plaintext oslt).

Steps to reproduce

Run jwt -j with an expired token for instance

Expected behavior

Return plain JSON wrapping the current one with something like that without color codes:
{
"result: {
"error": "The JWT provided is invalid because Error(Base64(InvalidByte(85, 61)))"
}
"header": {
"typ": "JWT",
"alg": "ES256",
[...]

@mike-engel
Copy link
Owner

Sorry for the late reply @hingehe. Can you tell me a bit more about your programming tool? Is it a TTY or not? Anything else I could look for to strip color and formatting?

@hingehe
Copy link
Author

hingehe commented Sep 30, 2022

I am working with a EAI Tool called "inubit".
grafik

I execute your script with a "CLI Execution module" on a linux system (so I think it is a TTY-Tool in your sense). The result (refer my previous post) has weird characters. My tool tries to wrap everything into an XML structure. This fails, whit these color coding characters, because of charset foo.
I fixed the problem with replace (regular expressions) in my CLI script, so I remove those characters. But this is of course not the best option. An optional parameter to suppress any color codings would be perfect for my needs.

@mike-engel
Copy link
Owner

Hi again @hingehe, sorry for the delayed response. The output crate I use is bunt, which uses termcolor itself. bunt will automatically print to stdout with the auto color mode. In that mode, output on windows won't be colored, but also if the environment variable NO_COLOR is defined, then it won't output colors.

That being said, can you try defining NO_COLOR in your environment and see if that works for you? If it does, I'll find a place to document it 😄

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

No branches or pull requests

2 participants