Recent

Author Topic: laz-JSON-Viewer a JSON viewer  (Read 2917 times)

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1111
  • Professional amateur ;-P
laz-JSON-Viewer a JSON viewer
« on: March 13, 2021, 08:53:39 pm »
Hi All,

I've started developing a JSON viewer called laz-JSON-Viewer.

It displays JSON in both textual and tree format.

It's supposed to be used from a file manager and the Windows Setup binary takes care of making it the default viewer for JSON.
There are instructions on how to do it for Linux on the README.

It can also be used from the command line with multiple files.

Please tell me what you think and, as usual, any help is welcomed and really appreciated.

Cheers,
Gus
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1111
  • Professional amateur ;-P
Re: laz-JSON-Viewer a JSON viewer
« Reply #1 on: March 13, 2021, 08:55:31 pm »
Hi all,

A new release, now with the ability to view in text mode by using F12.

laz-JSON-Viewer on GitHub

Notes from release v0.1.9.34:
  • Added a tab with Text view. Toggle with F12 (#15)
    This idea came from Craig Chapman(@chapmanworld)


At the moment I've released binaries of version v0.1.9.34 for these architectures:

Cheers,
Gus
« Last Edit: March 13, 2021, 08:57:19 pm by gcarreno »
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1111
  • Professional amateur ;-P
Re: laz-JSON-Viewer a JSON viewer
« Reply #2 on: March 19, 2021, 01:00:48 am »
Hi all,

A new release with a bug fixed.

laz-JSON-Viewer on GitHub

Notes from release v0.1.9.37:
  • Fix: Sometimes an error was thrown due to improper clearance of the value panel


At the moment I've released binaries of version v0.1.9.37 for these architectures:

Cheers,
Gus
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

PierceNg

  • Sr. Member
  • ****
  • Posts: 369
    • SamadhiWeb
Re: laz-JSON-Viewer a JSON viewer
« Reply #3 on: March 19, 2021, 02:11:44 am »
Nice. When used on the command line, does the program take standard input? If it does, then can pipe input from https://github.com/stedolan/jq. Or maybe your program can call jq as a filter?

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1111
  • Professional amateur ;-P
Re: laz-JSON-Viewer a JSON viewer
« Reply #4 on: March 19, 2021, 02:52:23 am »
Hi PierceNg,

Nice. When used on the command line, does the program take standard input? If it does, then can pipe input from https://github.com/stedolan/jq. Or maybe your program can call jq as a filter?

stdin
At this moment it doesn't take from stdin, and I still need to investigate if I want that, and if I do, how.
  • You can save JSON to a file and then use the filename as a commad line param.
  • You can save JSON to a file and then Drag-and-Drop it on the form, as many as you want.
  • You can make the viewer the default viewer for JSON and then just double click on your file manager.
    On the README.md there is information on how to hack it on Linux.
    The Windows installer will ask if you want to make it the default JSON viewer.

jq
You don't need jq, since the application will take any JSON compliant file and display it, both, in tree format and formatted text format.
This is pretty much jq with a GUI.

And many thanks for your attention and praise!!

Cheers,
Gus
« Last Edit: March 19, 2021, 02:55:48 am by gcarreno »
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

PierceNg

  • Sr. Member
  • ****
  • Posts: 369
    • SamadhiWeb
Re: laz-JSON-Viewer a JSON viewer
« Reply #5 on: March 19, 2021, 04:28:49 am »
jq
You don't need jq, since the application will take any JSON compliant file and display it, both, in tree format and formatted text format.
This is pretty much jq with a GUI.

jq is not just a JSON pretty-printer. It has a query language. Here's an example of jq's query/filter language that extracts data of interest from the deeply-nested JSON returned by AWS EC2 'describe-instances' API call:

jq '.Reservations[] | .Instances[] | {
   Id: .InstanceId,
   PublicAddress: .PublicIpAddress,
   PrivateAddress: .PrivateIpAddress,
   State: .State.Name,
   Reason: .StateTransitionReason,
   KeyName: .KeyName,
   SecurityGroups: .SecurityGroups[].GroupName
  }'

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1111
  • Professional amateur ;-P
Re: laz-JSON-Viewer a JSON viewer
« Reply #6 on: March 19, 2021, 04:54:03 am »
Hey PierceNg,

jq is not just a JSON pretty-printer. It has a query language. Here's an example of jq's query/filter language that extracts data of interest from the deeply-nested JSON returned by AWS EC2 'describe-instances' API call:

I'm aware of the capabilities of jq, since I have it installed on my machine and have used the filtering side of it many times in the past.

If I can draw a parallel into a GUI side of things, what you're asking me is to have a TEdit, somewhere, in which one types some XPath / jq filtering and the tree and JSON tabs react to it like the filter from jq, right?

I guess I can create an issue with that feature request, if it gathers momentum and wide support.
I think the XPath only can be done rather quickly, but I'm not gonna copy jq's behaviour. That would be re-inventing the wheel.
In regards to any jq related filtering, I would do a call to it and that would mean an external dependency for Linux and I'm not even sure if jq is supported on Windows.
Food for thought...

But from my understanding, jq is a good tool to use in scripts. What would you do with a filtered result? Copy/Paste? Rather lengthy, IMO.
If someone can give me a few good examples where a trimming of the full data with, either, an XPath or a jq type filter would make sense on a GUI, I'll then try to implement it, I guess.

Cheers,
Gus
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1111
  • Professional amateur ;-P
Re: laz-JSON-Viewer a JSON viewer
« Reply #7 on: March 19, 2021, 04:58:00 am »
Hi all,

A new release with a, rather embarassing, bug fixed.

laz-JSON-Viewer on GitHub

Notes from release v0.1.9.38:
  • Fix: The app now responds to language environment and translates itself
    Current only language: Portuguese(Portugal)


At the moment I've released binaries of version v0.1.9.38 for these architectures:

Cheers,
Gus
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

PierceNg

  • Sr. Member
  • ****
  • Posts: 369
    • SamadhiWeb
Re: laz-JSON-Viewer a JSON viewer
« Reply #8 on: March 19, 2021, 05:22:18 am »
If I can draw a parallel into a GUI side of things, what you're asking me is to have a TEdit, somewhere, in which one types some XPath / jq filtering and the tree and JSON tabs react to it like the filter from jq, right?

Hi Gus,

Yes, similar to those regular expression visualization tools - load some strings, type a regex, see what the regex returns.

But from my understanding, jq is a good tool to use in scripts. What would you do with a filtered result? Copy/Paste? Rather lengthy, IMO.
If someone can give me a few good examples where a trimming of the full data with, either, an XPath or a jq type filter would make sense on a GUI, I'll then try to implement it, I guess.

Copy/paste, but the other way round - use the GUI tool to develop the jq expression, copy/paste the final working expression into script for automation. (Of course this is already doable today without any GUI tool, by using text editor and command line (edit: and copy/pasting from Stackoverflow  :P)).

Pierce

« Last Edit: March 19, 2021, 05:27:54 am by PierceNg »

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1111
  • Professional amateur ;-P
Re: laz-JSON-Viewer a JSON viewer
« Reply #9 on: March 19, 2021, 07:50:23 pm »
Hey Pierce,

Yes, similar to those regular expression visualization tools - load some strings, type a regex, see what the regex returns.

Awww man I loved those!! Those saved my bacon once when I was a very rookie programmer and got thrown some regex usage. Of course, then I ad 2 problem, right? LOL!!

Copy/paste, but the other way round - use the GUI tool to develop the jq expression, copy/paste the final working expression into script for automation. (Of course this is already doable today without any GUI tool, by using text editor and command line (edit: and copy/pasting from Stackoverflow  :P)).

I took some time to answer to this one because I wasn't sure of some things, so I slept on it.

My take is this: laz-JSON-Viewer is intended to be a viewer. And a simple one at best. Any whistles and bells I attach, will be to enhance the viewing experience, never to tack on extra bits that can be a whole'nother application.

If I'm not mistaken, you can ask jq to output just strings or numbers, e.g., the leaf nodes of some JSON. That is a problem when you have a JSON viewer that expects to always have a well formed JSON input, right?

So in light of this, I guess I could do a similar app like the regex one, but for jq only. I'll have a thought about that if it's something that gains traction.
It wouldn't be that much work to conjure up a GUI frontend to jq, if I put my mind to it.

Cheers,
Gus
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

 

TinyPortal © 2005-2018