JSON lib for AutoHotkey
Requirements: AutoHotkey v1.1.21.00+ or v2.0-a
Version: v1.2.00.00 (updated 03/28/2015)
License: WTFPL
Works on both AutoHotkey v1.1 and v2.0a
Use #Include JSON.ahk
or #Include <JSON>
. Must be copied into a function library folder for the latter.
Deserialize src (a JSON formatted string) to an AutoHotkey object
obj := JSON.Load( ByRef src [, jsonize := false ] )
An AutoHotkey object
- src [in, ByRef] - JSON formatted string
- jsonize [in, opt] - if true, objects(
{}
) and arrays([]
) are wrapped as JSON.Object and JSON.Array instances respectively. This is to compensate for AutoHotkey's non-distinction between these types and other AHK object type quirks. e.g.: In AutoHotkey, object keys are enumerated in alphabetical order not in the sequence in which they are created
Serialize obj to a JSON formatted string
str := JSON.Dump( obj, [, indent := "" ] )
A JSON formatted string
- obj [in] - AutoHotkey object. Non-standard AHK objects like COM, Func, FileObject, RegExMatchObject are not supported.
- indent [in, opt] -if indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level. Blank(
""
) (the default) or0
selects the most compact representation. Using a positive integer indent indents that many spaces per level. If indent is a string (such as"`t"
), that string is used to indent each level. (I'm lazy, wording taken from Python docs)
For compatibilty with existing scripts using this lib. Calls to .parse()
and .stringify()
are cast to .Load()
and .Dump()
respectively.
Similar to the JSON class above just implemented as a function. Unlike JSON (class) above, this implementation provides reading from and writing to file(Removed Jxon_Read
and Jxon_Write
). Works on both AutoHotkey v1.1 and v2.0a
Use #Include Jxon.ahk
or #Include <Jxon>
. Must be copied into a function library folder for the latter.
Deserialize src (a JSON formatted string) to an AutoHotkey object
obj := Jxon_Load( ByRef src [ , object_base := "", array_base := "" ] )
- src [in, ByRef] - JSON formatted string or path to the file containing JSON formatted string.
- object_base [in, opt] - an object to use as prototype for objects(
{}
) created during parsing. - array_base [in, opt] - an object to use as prototype for arrays(
[]
) created during parsing.
Serialize obj to a JSON formatted string
str := Jxon_Dump( obj [ , indent := "" ] )
A JSON formatted string.
- obj [in] - this argument has the same meaning as in JSON.Dump()
- indent [in, opt] - this argument has the same meaning as in JSON.Dump()