Features:
- Supports object references including circular refs. See remarks
- Load input from string or file (de-serialize)
- Dump object to string or file (serialize)
- Uses AHK's escape sequence specifications (unlike JSON which uses \)
Serialize - See README -> Serilaize for parameter details OR check documentation within source code
Code: Select all
str := SerDes( obj )
bytes_written := SerDes( obj [, outfile ] )
Code: Select all
obj := SerDes( src )
obj := SerDes( file )
Code: Select all
#Include SerDes.ahk
ref := ["Hello"]
obj := [{"Hello":"Hello`nWorld"}, {(ref):"World"}, ref] ;// Object to serialize
; 1 2 3 4
;// Shows '[ {"Hello":"Hello`nWorld"}, { ["Hello"]:"World"}, $4]'
MsgBox % out := SerDes(obj) ;// Serialize and display output
obj := SerDes(out) ;// De-serialize
MsgBox % obj[1].Hello ;// displays "Hello`nWorld" -> Escape sequence
MsgBox % obj[2][obj[3]] ;// displays "World" -> Object reference at work
return
Remarks:
v2 Support - Due to the changes in objects built-in functions, this wont work for A_AhkVersion < v2.0-a049