#include "Chilkat.au3" _Example() Func _Example() _ErrorLog_ChilkatWrapper(ConsoleWrite) _Chilkat_StartUp() _Example_12_JsonObject_PrettyPrint() _Example_13_JsonObject_IterateMembers() _Example_14_JsonObject_CreateDocument() EndFunc Func _Example_12_JsonObject_PrettyPrint() _Log_ChilkatExample('_Example_12_JsonObject_PrettyPrint') ; https://www.example-code.com/vbscript/json_pretty_print.asp Local $oJSON = _Chilkat_JSON_ObjCreate() If @error then Return SetError(@error, @extended, $CHILKAT_RET_FAILURE) Local $sJSON_String = "{""name"": ""donut"",""image"":{""fname"": ""donut.jpg"",""w"": 200,""h"": 200},""thumbnail"":{""fname"": ""donutThumb.jpg"",""w"": 32,""h"": 32}}" Local $iSuccess = $oJSON.Load($sJSON_String) If ($iSuccess <> 1) Then ConsoleWrite($oJSON.LastErrorText & @CRLF) Return SetError(@error, @extended, $CHILKAT_RET_FAILURE) EndIf ; To pretty-print, set the EmitCompact property equal to 0 $oJSON.EmitCompact = 0 ; If bare-LF line endings are desired, turn off EmitCrLf ; Otherwise CRLF line endings are emitted. $oJSON.EmitCrLf = 0 ; Emit the formatted JSON: ConsoleWrite($oJSON.Emit() & @CRLF) EndFunc ;==>_Example_12_JsonObject_PrettyPrint Func _Example_13_JsonObject_IterateMembers() _Log_ChilkatExample('_Example_13_JsonObject_IterateMembers') ; https://www.example-code.com/vbscript/json_iterate_members.asp Local $oJSON = _Chilkat_JSON_ObjCreate() If @error then Return SetError(@error, @extended, $CHILKAT_RET_FAILURE) Local $sJSON_String = "{ ""id"": 1, ""name"": ""A green door"", ""tags"": [""home"", ""green""], ""price"": 125 }" Local $iSuccess = $oJSON.Load($sJSON_String) If ($iSuccess <> 1) Then ConsoleWrite($oJSON.LastErrorText & @CRLF) Return SetError($CHILKAT_ERR_LOAD, @extended, $CHILKAT_RET_FAILURE) EndIf Local $sName = '', $sValue = '' Local $iNumMembers = $oJSON.Size, $iValue=0 For $iMember_idx = 0 To $iNumMembers - 1 $sName = $oJSON.NameAt($iMember_idx) $sValue = $oJSON.StringAt($iMember_idx) ConsoleWrite($sName & ": " & $sValue & @CRLF) $iValue = $oJSON.IntAt($iMember_idx) ConsoleWrite($sName & " as integer: " & $iValue & @CRLF) Next EndFunc ;==>_Example_13_JsonObject_IterateMembers Func _Example_14_JsonObject_CreateDocument() _Log_ChilkatExample('_Example_14_JsonObject_CreateDocument') ; https://www.example-code.com/vbscript/create_json.asp Local $oJSON = _Chilkat_JSON_ObjCreate() If @error then Return SetError(@error, @extended, $CHILKAT_RET_FAILURE) $oJSON.AddStringAt(-1,"Title","Pan's Labyrinth") $oJSON.AddStringAt(-1,"Director","Guillermo del Toro") $oJSON.AddStringAt(-1,"Original_Title","El laberinto del fauno") $oJSON.AddIntAt(-1,"Year_Released",2006) $oJSON.EmitCompact = 0 ConsoleWrite($oJSON.Emit() & @CRLF) EndFunc ;==>_Example_13_JsonObject_IterateMembers Func _Log_ChilkatExample($sData) ConsoleWrite('>+ ' & $sData & @CRLF) EndFunc