pyTelegramBotAPI icon indicating copy to clipboard operation
pyTelegramBotAPI copied to clipboard

make json viewer more clear (reopen)

Open z44d opened this issue 1 year ago • 19 comments

reopened #2334

z44d avatar Jul 21 '24 15:07 z44d

I propose:

  • Storing json_string, with 'from' being changed to 'from_user'
  • When printing an object, this json_string should be printed.

And then, we can add some JSON_FORMATTED = FALSE or something like this to types.

@Badiboy need your opinion. This way, users will be able to see a CLEAR response from Telegram.

coder2020official avatar Jul 21 '24 16:07 coder2020official

This way, users will be able to see a CLEAR response from Telegram.

Debug mode have full and clear responces of the Telegram.

  • Storing json_string, with 'from' being changed to 'from_user'

I have no willing to waste my and others server resources for storing json strings that I never used before and will never use in future for the only purpose that one guy after several years of library existence occasionally decided to have pretty output.

Except you will make it SO OPTIONAL that it will affect NOBODY except they obviously decided to use it.

Badiboy avatar Jul 21 '24 16:07 Badiboy

I have no willing to waste my and others server resources for storing json strings

Makes sense

We still need changes to the output of the types though; Then, we can stick to the current implementation, but with pretty-printing optional. I have personally encountered parts where outputting classes is SO annoying: 99% of values shown are None. I have to turn debug afterwards. While debug is still needed, I see it reasonable to remove None values by default; And make pretty-printing optional by default.

coder2020official avatar Jul 21 '24 16:07 coder2020official

I have nothing against pretty output as I said from the very beginning which is:

  1. Optional
  2. Not consuming resources for those who do not need it

Intermediate version that was discussed that allowed:

  1. Optionally enable pretty output
  2. Optionally disable NONEs

Looked fine for me.

Badiboy avatar Jul 21 '24 16:07 Badiboy

Is disabling Nones by default fine with you?

coder2020official avatar Jul 21 '24 16:07 coder2020official

Mmm... Let's be like that as far as Nones are really useless and it should be more or less clear that if you do not see property - it's empty.

Badiboy avatar Jul 21 '24 16:07 Badiboy

Well I don't see any use case for seeing Nones. They are useless as API does not provide them. They just take up space, nothing useful out of this.

coder2020official avatar Jul 21 '24 16:07 coder2020official

Allright! @2ei then could you please:

Create 2 variables:

  1. JSONDESERIALIZABLE_PARSE_OUTPUT = False
  2. JSONDESERIALIZABLE_SKIP_NONE = True

Use these to pretty print and output None values if necessary.

coder2020official avatar Jul 21 '24 17:07 coder2020official

@coder2020official Done

Aslo, what about adding JSONDESERIALIZABL_PARSE_INDENT = 2 too?

z44d avatar Jul 21 '24 18:07 z44d

@badiboy do you think parse indent is this necessary

coder2020official avatar Jul 22 '24 06:07 coder2020official

parse indent

What's that?

Badiboy avatar Jul 22 '24 07:07 Badiboy

@2ei just implement it, won't hurt

coder2020official avatar Jul 25 '24 13:07 coder2020official

Thanks for the PR. Will test it out ASAP

coder2020official avatar Jul 27 '24 14:07 coder2020official

@2ei Thank you. LGTM if pass tests. )

Badiboy avatar Jul 30 '24 22:07 Badiboy

Screenshot 2024-08-11 at 4 55 16 PM LGTM. Just one more think: @badiboy do you think it would be better if this PR also removes json field in the output? or do you think it will be necessary? It is just a repetition of the whole dict.

coder2020official avatar Aug 11 '24 11:08 coder2020official

Romoving json looks reasonable: no need to duplicate the same data.

Badiboy avatar Aug 11 '24 18:08 Badiboy

Romoving json looks reasonable: no need to duplicate the same data.

what should i do in your opinion?, convert json parameter to property method or just make an condition in JsonDeserializable ?

Also i just noticed that there is no type hint for json parameter, on my way to add it too.

z44d avatar Aug 11 '24 19:08 z44d

LGTM. What did we agree on json?

coder2020official avatar Aug 31 '24 18:08 coder2020official

Romoving json looks reasonable: no need to duplicate the same data.

what should i do in your opinion?, convert json parameter to property method or just make an condition in JsonDeserializable ?

Also i just noticed that there is no type hint for json parameter, on my way to add it too.

idk, i have 2 suggestions here, what is the best one for you @coder2020official ?

z44d avatar Aug 31 '24 19:08 z44d

@badiboy this has been on for a long time. do you think we should convert json to property?

coder2020official avatar Nov 01 '24 12:11 coder2020official