https://github.com/rylefisher/jsons-for-ahkv2
Jsons.ahk for AHKv2, the lazy man's Json. Handles and converts objects and classes. Also functions as obj -> str converter.
https://github.com/rylefisher/jsons-for-ahkv2
ahk ahkv2 autohotkey autohotkeyv2 json
Last synced: about 1 year ago
JSON representation
Jsons.ahk for AHKv2, the lazy man's Json. Handles and converts objects and classes. Also functions as obj -> str converter.
- Host: GitHub
- URL: https://github.com/rylefisher/jsons-for-ahkv2
- Owner: rylefisher
- Created: 2023-06-25T07:12:31.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-19T12:32:49.000Z (over 2 years ago)
- Last Synced: 2025-04-14T21:52:33.459Z (about 1 year ago)
- Topics: ahk, ahkv2, autohotkey, autohotkeyv2, json
- Language: AutoHotkey
- Homepage:
- Size: 43 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Jsons.ahk for AHKv2
The lazy man's json. Inspired by: https://pypi.org/project/jsons/
Forked from TheArkive https://github.com/TheArkive/JXON_ahk2
This is a normal Json library, with a built in function to handle and convert all Objects to Maps. Feed anything into Dump, and it should return a proper serialized string. Autohotkeyv2 & AHKv2
# Use
Serialize
```autohotkey
var := Jsons.Dump(obj, indent:=0)
```
Convert to obj
```autohotkey
obj := Jsons.Load(&text)
```
In the future, I'll try to convert to objects a la https://github.com/Jim-VxE/AHK-Lib-JSON_ToObj
test input:
```autohotkey
class Test
{
__New(){
this.valA := "valA"
this.valB := "valB"
}
}
ClassObj := Test()
ObjB := {1:2}
MapA := Map("test", {ObjB:"x"})
x := {
ClassObjects: [ClassObj,ClassObj],
1: 2,
4: [1, ClassObj],
z: Map(1,2),
ObjB:ObjB,
y:MapA
}
jdata := Jsons.Dump(x, indent:=2)
```
output:
```json
{
"1": 2,
"4": [
1,
{
"valA": "valA",
"valB": "valB"
}
],
"ClassObjects": [
{
"valA": "valA",
"valB": "valB"
},
{
"valA": "valA",
"valB": "valB"
}
],
"ObjB": {
"1": 2
},
"y": {
"test": {
"ObjB": "x"
}
},
"z": {
"1": 2
}
}
```