A small JSON library for AutoIt3
#include "json.au3"
$sJson = '{"name":"John","age":31,"city":"New York"}'
$oJson = _json_decode($sJson)
MsgBox(0, "", $oJson['name'])
; change value of $__g_json_sPrettyIndentation, to adjust identation in pretty print
ConsoleWrite(_json_encode_pretty($oJson)&@CRLF)
When an error occurs in a JSON function, @error is set to non zero and a string describing the error with offset position is returned.
#include "json.au3"
$sJson = '{"name":"John","age"}'
$oJson = _json_decode($sJson)
If @error <> 0 Then
ConsoleWriteError($oJson&@CRLF) ; Unexpected character: "}" at offset: 21
Exit
EndIf
ConsoleWrite($oJson['name']&@CRLF)
AutoIt version 3.3.14.0 or greater