Skip to content

Instantly share code, notes, and snippets.

@dadamssg
Last active September 9, 2022 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dadamssg/0a5f15c82af49ac8df80466d6bc39fdc to your computer and use it in GitHub Desktop.
Save dadamssg/0a5f15c82af49ac8df80466d6bc39fdc to your computer and use it in GitHub Desktop.
// Name: format-json
// Shortcut: cmd shift j
// Author: David Adams
// Twitter: @dadamssg
import "@johnlindquist/kit"
let jsonabc = await npm("jsonabc")
let text = await getSelectedText()
let json
try {
json = jsonabc.sort(String(text).trim(), false, 2)
} catch (e) {
notify(e.message)
exit()
}
await setSelectedText(json)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment