Advertisement
Guest User

FormatJson.vbs

a guest
Feb 16th, 2017
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ' it will print all open files to printer
  2. const module_name  = "FormatJson"
  3. const module_ver   = "1.0"
  4.  
  5. sub JSONPretify
  6.   set obj = NewEditor()
  7.   obj.assignActiveEditor()
  8.  
  9.   set json = CreateObject("Chilkat_9_5_0.JsonObject")
  10.   success = json.Load(obj.text)
  11.   If (success <> 1) Then
  12.       WScript.Quit
  13.   End If
  14.  
  15.   '  To pretty-print, set the EmitCompact property equal to 0
  16.  json.EmitCompact = 0
  17.  
  18.   '  If bare-LF line endings are desired, turn off EmitCrLf
  19.  '  Otherwise CRLF line endings are emitted.
  20.  json.EmitCrLf = 1
  21.  
  22.   '  Emit the formatted JSON:
  23.  obj.text( json.Emit() )
  24. end sub
  25.  
  26. ' name "Init" is required, its called automatically during initialization to create menu items
  27. Sub Init
  28.     addMenuItem "JSON Pretify", "Format code", "JSONPretify", "Shift+Ctrl+J"
  29. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement