Skip to content

Latest commit

 

History

History
80 lines (70 loc) · 1.24 KB

README.md

File metadata and controls

80 lines (70 loc) · 1.24 KB

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

var := Jsons.Dump(obj, indent:=0)

Convert to obj

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:

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:

{
  "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
  }
}