chucker
chucker copied to clipboard
JSON Request/Response Body Syntax Color Highlighting
:warning: Is your feature request related to a problem? Please describe

:bulb: Describe the solution you'd like
:bar_chart: Describe alternatives you've considered
:page_facing_up: Additional context
:raising_hand: Do you want to develop this feature yourself?
- [x] Yes
- [ ] No
Would it be nice if we can display JSON like this?

Sounds like a valuable feature @seanghay. Just a couple of things to keep in mind:
- I'd love to make sure that the color scheme is configurable has good contrast ratio both in the light and the dark background.
- In this page there is also a "search" feature that will highlight the found occurrences of a string you search. Please make sure that it still works correctly.
- Performance is really important in this page. We already worked on the body page and refactored to use a
RecyclerViewwith one entry per line. Please make sure that adding a syntax highlighting won't impact the performance of this page significantly.
@cortinico Is is slow to set everything into a single TextView rather than using RecyclerView to render each line?
Regarding search - there will be my PR this week changing it a little bit. Just be aware.
@seanghay As to putting everything into one TextView - yes, it is slow. On some big responses it caused ANR errors. This is why we switched to RecyclerView.
Thanks @vbuberen. I will start looking into it and hopefully will open a pull request soon.
Would like to to give a heads up on this issue - I started to play around with MergeAdapter, which looks a great thing for lots of improvements, including this feature request. While it is still in alpha we can't let it go into the library, but I will open a draft PR to have it visible and maybe inspire someone.
Hi @seanghay, how is it going your working? It's a really good feature request, if you want I can help you for delivering the feature.
Hi @seanghay, how is it going your working? It's a really good feature request, if you want I can help you for delivering the feature.
Hi @mertceyhan! I haven't worked on it yet, if you can help that would be great.
It's not looking possible when using with as a recyclerView item. Because deciding it's a key or value in a single line is so hard. Has it really different performance when we use recyclerView or single textView? @vbuberen @cortinico
It's not looking possible when using with as a recyclerView item. Because deciding it's a key or value in a single line is so hard. Has it really different performance when we use recyclerView or single textView? @vbuberen @cortinico
I think you can create a SpannableString with Syntax Highlighting before splitting it into lines, so each line is a SpannableString which keeps its colors, and then it will render the same as using a TextView.
The challenging part for me is to tokenize the JSON string and highlight all syntaxes.
@mertceyhan
We switched from TextView, because we had an issue reported about poor performance on some big responses.
In general, I believe that current RecyclerView implementation is the best solution at the moment till we switch to Jetpack Compose (when it reaches some stable state).
Agree with your point on trying to distinguish key and value. This is what stopped us and other contributors so far, I guess.
But I believe that there is a solution for future. Since we are going to introduce some breaking changes in 4.x release we also have plans on redesigning database entities to have separate Transaction, Request and Response models. And in these redesigned models I thought we could change the way how we store the payload to not have just a big String there.
So I would suggest to not spend time on this issue at the moment till we present something more suitable for such customizations.
@vbuberen Thanks for the explanation.
I just fork to use webview and use function of https://highlightjs.org/
but not tested heavily; https://github.com/esabook/chucker