Web developers often handle unformatted Json data, all in one line. Often hard to read, when the amount of data increases. In the past, I wrote a Lua script for SciTE to format Json. With CopyQ, the task is trivial.
Code:
[Command]
Name=Paste formatted Json
Command="
copyq:
var text = str(input())
try {
var json = JSON.parse(text)
// Remplace '\\t' with a number to indent
// with this amount of spaces
text = JSON.stringify(json, null, '\\t')
} catch (e) {
}
copy(text)
paste()
"
Input=text/plain
InMenu=true
HideWindow=true
Icon=\xf121
Description:
Pastes selected Json text as a formatted Json text.
If not Json, just pastes the text as is.
Web developers often handle unformatted Json data, all in one line. Often hard to read, when the amount of data increases. In the past, I wrote a Lua script for SciTE to format Json. With CopyQ, the task is trivial. Code:
Description: Pastes selected Json text as a formatted Json text. If not Json, just pastes the text as is.