samuelraub Posted June 21 Share Posted June 21 (edited) I'm the author Github: https://github.com/samuelraub/pretty-json-alfred-workflow From the About Page: This workflow formats JSON. Getting Started Pretty JSON takes a JSON string from your clipboard, formats it and copies it back to your clipboard. Just copy some JSON and run it by typing `pj` in Alfred. Advanced You can set the default indent depth in the workflow configuration. Default is 2 spaces. You can give `pj` a number as an argument to override the default indent depth You can run pj as a text action Sample JSON for testing: {"foo": 1, "bar": 2, "alfred": "cool"} [{"foo": "bar"}, {"baz": 1}] Edited June 21 by samuelraub Link to comment Share on other sites More sharing options...
vitor Posted June 21 Share Posted June 21 1 hour ago, samuelraub said: You can run pj as a text action That happens because you have the checkbox ticked under Alfred Preferences → Features → Universal Actions → Actions. To make it available to everyone, add an explicit Universal Action Trigger. Link to comment Share on other sites More sharing options...
samuelraub Posted June 21 Author Share Posted June 21 45 minutes ago, vitor said: That happens because you have the checkbox ticked under Alfred Preferences → Features → Universal Actions → Actions. To make it available to everyone, add an explicit Universal Action Trigger. Thanks! Will look into it and ping you once changed 🙂 vitor 1 Link to comment Share on other sites More sharing options...
samuelraub Posted June 22 Author Share Posted June 22 (edited) Hey @vitor, I've updated the workflow with the following changes: Maybe it would be nice to make `Post a Notification if input JSON is invalid` optional from the workflow config? Let me know what you think 🙂 Edited June 22 by samuelraub add an idea Link to comment Share on other sites More sharing options...
samuelraub Posted June 22 Author Share Posted June 22 (edited) Another idea: Maybe it would be nice to expose an option in workflow config to anyway copy the input JSON, even if it's invalid. Implementation in this branch: https://github.com/samuelraub/pretty-json-alfred-workflow/tree/feat/copy-invalid-input Edited June 22 by samuelraub add branch link Link to comment Share on other sites More sharing options...
vitor Posted June 22 Share Posted June 22 2 hours ago, samuelraub said: Maybe it would be nice to make `Post a Notification if input JSON is invalid` optional from the workflow config? Doesn’t seem necessary. If the JSON is invalid it’s useful to know about it. 2 hours ago, samuelraub said: Maybe it would be nice to expose an option in workflow config to anyway copy the input JSON, even if it's invalid. Up to you. If the JSON is invalid, I’d say the clipboard should remain unchanged. Found an issue, though. The Universal Action is working well, but the pj keyword isn’t. If I give it no argument it always returns that the JSON is invalid, and if I do give an argument (e.g. 4) it copies that number to the clipboard instead. Link to comment Share on other sites More sharing options...
samuelraub Posted June 23 Author Share Posted June 23 23 hours ago, vitor said: Found an issue, though. The Universal Action is working well, but the pj keyword isn’t. If I give it no argument it always returns that the JSON is invalid, and if I do give an argument (e.g. 4) it copies that number to the clipboard instead. Of course. Fixed on `main`! @vitor - I decided to still include the option to copy invalid, because users might fix the "invalidness" manually in an editor or something, yet disabled it by default in the workflow config Link to comment Share on other sites More sharing options...
vitor Posted June 23 Share Posted June 23 You should always fill the Checkbox Text to the right. That’s what screen readers speak to users. So something like Notification [x] Show error when JSON is invalid (probably won’t even need the description underneath). Same for the copy. Link to comment Share on other sites More sharing options...
samuelraub Posted June 23 Author Share Posted June 23 @vitor Like so? (Sorry to ping you everytime. LMK if that's inappropriate 🙂 ) Link to comment Share on other sites More sharing options...
vitor Posted June 23 Share Posted June 23 Just now, samuelraub said: Like so? Looks good! Ideally the description text would start with an uppercase letter and end with a period (see Alfred’s own settings) but that’s not necessarily a problem for this initial version. I’ll take another full look shortly. 1 minute ago, samuelraub said: Sorry to ping you everytime. LMK if that's inappropriate It’s fine in this context. But it’s also unnecessary because I’ll get pinged anyway when you make a reply on the thread, regardless if you @vitor or not. Link to comment Share on other sites More sharing options...
samuelraub Posted June 23 Author Share Posted June 23 Cool! Thank you! Updated on `main` Link to comment Share on other sites More sharing options...
vitor Posted June 24 Share Posted June 24 In the process of adding it, found one extra thing. The bundle ID cannot start with com.alfredapp because a bundle ID is supposed to be the author’s domain. If you don’t have one, you can use app.alfred.samuelraub.prettyjson. Also, as a tip: The pj subtitle should probably mention it will use the JSON in the clipboard, to add a bit of clarity for the user. samuelraub 1 Link to comment Share on other sites More sharing options...
samuelraub Posted June 28 Author Share Posted June 28 On 6/24/2023 at 8:30 PM, vitor said: n the process of adding it, found one extra thing. The bundle ID cannot start with com.alfredapp because a bundle ID is supposed to be the author’s domain. If you don’t have one, you can use app.alfred.samuelraub.prettyjson. Would `de.samuelraub.prettyjson` work? On 6/24/2023 at 8:30 PM, vitor said: Also, as a tip: The pj subtitle should probably mention it will use the JSON in the clipboard, to add a bit of clarity for the user. How about `Prettify the last clipboard item`? Sorry. Was super busy the last couple of days. Link to comment Share on other sites More sharing options...
vitor Posted June 28 Share Posted June 28 Just now, samuelraub said: Would `de.samuelraub.prettyjson` work? Yes, that’s even better. 1 minute ago, samuelraub said: How about `Prettify the last clipboard item`? Great too! Link to comment Share on other sites More sharing options...
samuelraub Posted June 28 Author Share Posted June 28 Awesome! Updated on main Link to comment Share on other sites More sharing options...
vitor Posted June 28 Share Posted June 28 Thank you for the changes. This will be live at https://alfred.app/workflows/samuelraub/pretty-json/ later today. samuelraub 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now