Here is demo python script that will format the json content (still in progress
of development for custom indentation!! )
cite:
--------------------------------------------------------------------------------
# imports
import json
pspad = globals()['global']
module_name = "FormatJSON";
module_ver = "1.1";
module_title = "FormatJSON";
def open_script():
"""Open this script in new editor window"""
new_editor = pspad.newEditor()
new_editor.openFile(pspad.moduleFileName("FormatJSON"))
def format_json():
"""Format the json content with indent 4"""
editor = pspad.newEditor()
editor.assignActiveEditor()
json_data = editor.text()
format_data = json.dumps(json.loads(json_data), indent=4)
new_editor = pspad.newEditor()
windowName = "__JSON__"
try:
new_editor.assignEditorByName(windowName)
except:
new_editor.newFile(windowName)
new_editor.text("")
new_editor.activate()
new_editor.highlighter("JSON")
new_editor.appendText(format_data)
def about():
pspad.echo(
"\n" + module_name + " " + module_ver + "\n\n" +
"PSPad Format JSON Script\n\n" +
"by Jigar,\n" +
"This script format the content of json file"
)
def Init():
pspad.addMenuItem("Format JSON", "JSON", "format_json")
pspad.addMenuItem("-","JSON","","")
pspad.addMenuItem("Edit this script", "JSON", "open_script")
pspad.addMenuItem("About", "JSON", "about")
--------------------------------------------------------------------------------
Thanks
--
<http://forum.pspad.com/read.php?2,65617,65662>
PSPad freeware editor http://www.pspad.com