Skip to content

Latest commit

 

History

History
40 lines (25 loc) · 792 Bytes

README.md

File metadata and controls

40 lines (25 loc) · 792 Bytes

au3json

A small JSON library for AutoIt3

usage

#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)

Error handling

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)

Requirements

AutoIt version 3.3.14.0 or greater