1

I have log files which are as below,

{ "date": "2020-02-15", "message": "something went wrong", "env": "production"}
{ "date": "2020-02-15", "message": "something went wrong", "env": "production"}
{ "date": "2020-02-15", "message": "something went wrong", "env": "production"}
{ "date": "2020-02-15", "message": "something went wrong", "env": "production"}
{ "date": "2020-02-15", "message": "something went wrong", "env": "production"}

As the file, itself is not a valid JSON file, but the individual line is valid JSON.

Is there any tool I can use it visualize in JSON structured way like below,

{
 "data": "2020-02-15",
 "message": "somehting went wrong",
 "env": production
}, 
....
0

I can highly recommend JSONedit. It serves as both a JSON viewer and JSON editor.

It features text, tree, and list views.

It is portable software and is free of cost (freeware). It even features a dark theme/mode.

The only issue I've had with it is that it crashes for me when I open very large (hundreds of MBs) JSON files. I'm hoping the author has time to fix that issue.

I've never had any problems with it with smaller JSON files.

If it wasn't for the crash with large files, I would give it 5 out of 5 lizards. With the crash when opening large files, I give it a highly respectable 4 out of 5 lizards.

JSON edit is available here: https://tomeko.net/software/JSONedit/

Here is a nice screenshot from the author's page: JSONedit Screenshot
Source: https://tomeko.net/software/JSONedit/JSONedit.png


EDIT: After spending some time composing this answer, I re-read your question. I realized that I initially missed a key word, "not" (as in file is not valid JSON), when quickly reading your question the first time. My apologies.

So I took your exact data and tried loading it into a JSONedit. As expected, it could read it and display is nicely, but not process it as JSON.

I then tried tweaking your data a little bit to see if I could quickly massage it into a valid JSON format. I only had a few more minutes of spare time, and I was unable to get it working.

I think you could definitely write a simple pre-processor to process your log files and then send the output to JSONedit, but the exact format you provided is unfortunately not compatible.

If this answer is of any use to you, great. If not, just leave a comment under it, and I'll delete my work.

1
  • 1
    NDJSON can be actually opened from Tools menu - kind of application-inside-application with simple filtering/marking allowing iterative work when filtering large logs. It can be either browsed from this window, with JSON values loaded to main window when selected or converted to single JSON array (first option would be better suited for large log files). – TMSZ Feb 9 at 13:26
0

This format is called NDJSON/LDJSON/JSONL. https://github.com/stedolan/jq fills requirements - open source and can be compiled on multiple platforms

0

Windows PowerShell (built-in to Windows) has a ConvertTo-Json command that you might be able to wrangle:

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/convertto-json?view=powershell-7.1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.