Live data from Hacker News

Show HN: JSON Pizza – Beautify your JSON quickly

json.pizza

71–80 of 81 posts

Re: Show HN: JSON Pizza – Beautify your JSON quickly

#71
post #27
post #19

Not to threadcrap, but I am curious what people think about this. Over the years I've seen a lot of developers take none open-source code, or private JSON data strings and paste them into random sites they find searching "json format" on google. Does that make anyone else cringe? Is there anything we can do about this? Or is this just not a big deal and I shouldn't worry.

I had a junior dev show me a neat site where you can paste in a Java thread dump and it performs an analysis. After explaining why it's a bad practice to send diagnostic details to an un-trusted third party I think he understood, but it seems like every week I'm finding people using ngrok, unauthorized password managers, grammarly, JWT parsers, Base64 encoders, and all manner of questionable tools. I too wonder if I'…

Leaking a bit of code will unlikely cause a problem, but the guns that can backfire are some of the cert checkers and SAML validators.

Re: Show HN: JSON Pizza – Beautify your JSON quickly

#72
post #36

Earlier quoted context omitted.

Still too dangerous, and I don't trust new developers to make that determination. Once you get into the habit of pasting development details into random website textboxes hosted who-knows-where with who-knows-what ad networks, you're one keystroke away from leaking sensitive details that are correlated to your employer's IP range. Or maybe I'm a crank and need to lighten up. That's why I'm asking.

Hum. I can see both cases. I would also think even if they copy/paste sensitive information. Like SSNs or password. It will be so diluted in the noise of other people data that it won't matter. Most of these websites - I made one myself - are run by people like us and we won't care about what it sent to the server.

Google offers a digital leak prevention service as part of GCP. You could use it for offensive security to find likely PII without much concern about the noise.

Google runs this (or an internal version) of this service to make sure people serving third party ads aren't sending sensitive data. At one of my past companies our customers would send out email marketing campaigns that contained URLs with tracking parameters with PII. We wound up having to just strip off any query parameters we didn't explicitly need because Google kept flagging us for PII leaks caused by our customers.

So yeah, there's a lot of noise. But, people are listening out there!

Re: Show HN: JSON Pizza – Beautify your JSON quickly

#73
post #67
post #26

Earlier quoted context omitted.

You can do the same in the browser console. I don't really get why people need an online tool for this: copy(JSON.stringify(obj, null, 2)) obj can be parsed with JSON.parse if it is in text.

> I don't really get why people need an online tool for this: That’s rather condescending, and probably not true. Surely you must be able to think of reasons why someone would use a website instead of writing a one-line program.

The only reason I can think of is if this is something which one very rarely needs. Otherwise, I'd think those who regularly handle JSON files are able to write a one line program.

And the JS console was only an example. Other languages can also pretty print JSON trivially. E.g. python.

Re: Show HN: JSON Pizza – Beautify your JSON quickly

#75
post #26
post #19

Not to threadcrap, but I am curious what people think about this. Over the years I've seen a lot of developers take none open-source code, or private JSON data strings and paste them into random sites they find searching "json format" on google. Does that make anyone else cringe? Is there anything we can do about this? Or is this just not a big deal and I shouldn't worry.

You can do the same in the browser console. I don't really get why people need an online tool for this: copy(JSON.stringify(obj, null, 2)) obj can be parsed with JSON.parse if it is in text.

On chrome at least copy(Paste json here) is enough

Re: Show HN: JSON Pizza – Beautify your JSON quickly

#77
post #17

Earlier quoted context omitted.

Or on macOS, to quickly format the contents of your clipboard: pbpaste | jq . | pbcopy Pretty sure this is one of my most frequent commands.

You can use Automator to create a service with a shell script action; just pick Quick Action, the rest should be pretty obvious.

Not so obvious to me ! I have created the Quick Action but I don't know how to trigger it, so I have saved it as an app. Also when I execute it from Automator (play button), the script doesn't work (nothing is pasted). Would you mind helping ? Looks the best way to quickly format a copied json ! Thanks

Re: Show HN: JSON Pizza – Beautify your JSON quickly

#78

OS X includes the json_pp command, so I often just do this to format JSON in my clipboard: pbpaste | json_pp | pbcopy For just viewing, I like Node's console.dir() formatting better since it's more compact and colored (but it's unquoted JS objects, not JSON), so I aliased this command in my shell: json='node -e '\''console.dir(JSON.parse(fs.readFileSync("/dev/stdin", "utf-8")), { depth: null })'\' Then I can do pbpas…

One of my absolute musts in a text editor is a feature that prompts for a command, pipes the selected text into it and replaces it with the command's output (for Visual Studio Code it comes as a plugin). So "Ctrl+A, Ctrl+\, 'json_pp', Enter" and voila, formatted JSON in my editor (Ctrl+\ is what the command is bound to). Also works great with grep, sort, awk...

Which VSCode plugin are you using for this? I’m not sure what to search to find it but it sounds handy :)

Re: Show HN: JSON Pizza – Beautify your JSON quickly

#79
post #18

Earlier quoted context omitted.

I want to like jq, and for doing a simple lookup it's great, but I find when I try to do something complicated the syntax just doesn't click.

I know, right? I've switched to using jp: its syntax is based on an actual standard and it clicks much more with me than jq's syntax. https://github.com/jmespath/jp

Nice! I didn’t actually realise JMESPath was a standard, I first came across it in the AWS CLI and definitely found it nicer than jq. Good to avoid trying to learn both.

Re: Show HN: JSON Pizza – Beautify your JSON quickly

#80
post #17

Earlier quoted context omitted.

You can use Automator to create a service with a shell script action; just pick Quick Action, the rest should be pretty obvious.

Not so obvious to me ! I have created the Quick Action but I don't know how to trigger it, so I have saved it as an app. Also when I execute it from Automator (play button), the script doesn't work (nothing is pasted). Would you mind helping ? Looks the best way to quickly format a copied json ! Thanks

Yeah, that was a very terse explanation, and Automator is so user-friendly it's hard to use.

1. Start Automator.

2. In the "Choose a type..." sheet, choose "Quick Action".

3. Set these:

     Workflow recieves "current text" in "any application".
     Input is "entire selection". [X] Output replaces text.
4. Add "Run shell script" and select your preferred shell.

     jq .
(Note that Automator is handling your stdin / stdout.)

5. File / Save.

You can now find your workflow by command-clicking the document name in the window's titlebar. It should be in /Users/You/Library/Services

Now, fire up TextEdit, enter some JSON. Right-click, select Services and your service should be present. It's also in the TextEdit menu under Services.

Post reply on HN