Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cocobelgica/AutoHotkey-SerDes
Serialize / de-serialize an AutoHotkey object structure
https://github.com/cocobelgica/AutoHotkey-SerDes
Last synced: 25 days ago
JSON representation
Serialize / de-serialize an AutoHotkey object structure
- Host: GitHub
- URL: https://github.com/cocobelgica/AutoHotkey-SerDes
- Owner: cocobelgica
- Created: 2014-08-03T07:47:16.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-09-18T13:17:47.000Z (about 10 years ago)
- Last Synced: 2024-08-05T01:10:49.948Z (4 months ago)
- Language: AutoHotkey
- Size: 184 KB
- Stars: 13
- Watchers: 3
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-AutoHotkey - SerDes - by cocobelgica - Serialize / de-serialize an AutoHotkey object structure. Forum thread: [link](https://autohotkey.com/boards/viewtopic.php?f=6&t=4212). (Libraries / <a name="libraries-data-format"></a>Data format)
README
# SerDes
#### Serialize / de-serialize an [AutoHotkey](http://ahkscript.org) [object](http://ahkscript.org/docs/Objects.htm) structure.Requires AHK _v1.1+_ OR _v2.0-a049+_
License: [WTFPL](http://wtfpl.net)
- - -
### Serialize
**Syntax**
```
str := SerDes( obj [ ,, indent := "" ] )
bytes := SerDes( obj, outfile [ , indent := "" ] )
```**Parameters**
```
str [retval] - String representation of the object
bytes [retval] - Bytes written to 'outfile'.
obj [in] - AHK object to serialize.
outfile [in, opt] - The file to write to. If no absolute path is specified, %A_WorkingDir% is used.
indent [in, opt] - If indent is an integer or string, then array elements and object members will
be pretty-printed with that indent level. Blank(""), the default, OR 0, selects
the most compact representation. Using an integer indent indents that many spaces
per level. If indent is a string, (such as "`t"), that string is used to indent
each level. Negative integer is treated as positive.
```### Deserialize
**Syntax**
```
obj := SerDes( src )
```**Parameters**
```
obj [retval] - An AHK object
src [in] - Either a 'SerDes()' formatted string or the path to the file containing 'SerDes()' formatted text.
```## Remarks:
* Serilaized output is similar to [JSON](http://json.org/) except for escape sequences which follows [AHK's specification](http://ahkscript.org/docs/commands/_EscapeChar.htm#Escape_Sequences_when_accent_is_the_escape_character). Also, strings, numbers and objects are allowed as `object/{}` keys unlike JSON which restricts it to string data type only.
* Non-standard AHK objects such as _COM_, _Func_, _FileObject_, _RegExMatchObject_ are not supported.
* Object references, including circular ones, are supported and notated as _$n_, where _n_ is the _1-based_ index of the referenced object in the heirarchy tree when encountered during enumeration _(for-loop)_ OR as it appears from left to right _(for string representation)_ as marked by an opening brace`{` or bracket`[`.
```javascript
1 2
{ "key1": ["Hello World"], "key2": $2 } // -> $2 references the object stored in 'key1'
```