Insomnia: Feature request: In json response show the size of array

Created on 22 Nov 2019  ยท  7Comments  ยท  Source: Kong/insomnia

  • Insomnia Version: ___
  • Operating System: ___

Details


In json response preview please add a feature to show the size of the array. As in my case array size has to be compared to confirm correct output so I have copy and go other application to just get a count.
e.g
json array size

accepted help wanted

Most helpful comment

Hey @gschier, I'd like to pick this one up! ๐Ÿ˜„

I forked CodeMirror and made a couple of additions to its fold.brace logic.

From what I could understand, it will be tricky to add the // 3 items as a comment without invalidating the JSON. There may be an add-on for this but I couldn't find one. Ignoring JSON invalidation, the implementation for commenting after a tag was getting unwieldy while I was experimenting as well.

In any case, I do think it would be nicer to add the count within the fold widget, instead of outside - that way there is one indicator and interaction point for folding, rather than two.

From a consumer perspective, you can currently override the fold widget. I introduced an itemsWidget field. I chose to separate the field so that the existing is kept as a fallback.

image

This itemsWidget only kicks in, in the case we have a valid item count. For example, with invalid JSON, the default fold widget <-> is used to preserve existing behavior.

Pending review in CodeMirror, but I figured I'd get my thoughts and decisions into words while they are fresh. ๐Ÿ˜„

All 7 comments

๐Ÿ‘‹ Thanks for opening your first issue! If you're reporting a ๐Ÿž bug, please make sure
you include steps to reproduce it. If you're requesting a feature ๐ŸŽ, please provide real
use cases that would benefit. ๐Ÿ‘ช

To help make this a smooth process, please be sure you have first read the
contributing guidelines.

I really like the idea of this, and it's been requested before I think too. Since Codemirror is responsible for folding code, it's probably best to implement this as a Codemirror plugin. Maybe there's already one out there?

Hey @gschier, I'd like to pick this one up! ๐Ÿ˜„

I forked CodeMirror and made a couple of additions to its fold.brace logic.

From what I could understand, it will be tricky to add the // 3 items as a comment without invalidating the JSON. There may be an add-on for this but I couldn't find one. Ignoring JSON invalidation, the implementation for commenting after a tag was getting unwieldy while I was experimenting as well.

In any case, I do think it would be nicer to add the count within the fold widget, instead of outside - that way there is one indicator and interaction point for folding, rather than two.

From a consumer perspective, you can currently override the fold widget. I introduced an itemsWidget field. I chose to separate the field so that the existing is kept as a fallback.

image

This itemsWidget only kicks in, in the case we have a valid item count. For example, with invalid JSON, the default fold widget <-> is used to preserve existing behavior.

Pending review in CodeMirror, but I figured I'd get my thoughts and decisions into words while they are fresh. ๐Ÿ˜„

Looks like my PR was merged in after some suggestions. Once the new version of CodeMirror containing this gets published I'll come back and update Insomnia ๐Ÿ˜„ will try and keep track of it!

Woah, that's awesome @develohpanda! That's a huge project to get a contribution into ๐Ÿ™Œ๐Ÿป

Yes, feel free to create a PR to bump the codemirror version once it's released ๐Ÿ’ซ

Hey thanks @gschier! It's an interesting project, very very vanilla js and so simple to get running.

I'm going to see how I might be able to contribute to codemirror.next - v6 rewritten in typescript!

Nice, I'm super excited for v6 to launch

Was this page helpful?
0 / 5 - 0 ratings