Skip to content

Jsons.ahk for AHKv2, the lazy man's Json. Handles and converts objects and classes. Also functions as obj -> str converter.

Notifications You must be signed in to change notification settings

samfisherirl/Jsons-for-AHKv2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 

Repository files navigation

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

About

Jsons.ahk for AHKv2, the lazy man's Json. Handles and converts objects and classes. Also functions as obj -> str converter.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published