DataFlex
DataFlex
Pretty Print JSON (Formatter, Beautifier)
See more JSON Examples
Demonstrates how to emit JSON in a pretty, human-readable format with indenting of nested arrays and objects.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoJson
String sJsonStr
String sTemp1
Move False To iSuccess
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Move '{"name": "donut","image":{"fname": "donut.jpg","w": 200,"h": 200},"thumbnail":{"fname": "donutThumb.jpg","w": 32,"h": 32}}' To sJsonStr
Get ComLoad Of hoJson sJsonStr To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoJson To sTemp1
Showln sTemp1
Procedure_Return
End
// To pretty-print, set the EmitCompact property equal to False
Set ComEmitCompact Of hoJson To False
// If bare-LF line endings are desired, turn off EmitCrLf
// Otherwise CRLF line endings are emitted.
Set ComEmitCrLf Of hoJson To False
// Emit the formatted JSON:
Get ComEmit Of hoJson To sTemp1
Showln sTemp1
End_Procedure