Giter Site home page Giter Site logo

autohotkey-json's Introduction

JSON and Jxon

JSON module for AutoHotkey

Requires AutoHotkey v1.1.17.00+ OR 2.0-a057+

License: WTFPL


JSON.ahk (class)

There are multiple version(s) available (as branches) in this repo to provide support for different AutoHotkey builds. The master branch is for v1.1 (except for Json2.ahk which is version independent) while the v2 branch is for AHK v2.0-a.


.parse()

Deserialize src (a JSON formatted string) to an AutoHotkey object

Syntax:

obj := JSON.parse( src [, jsonize := false ] )

Return Value:

An AutoHotkey object

Parameter(s):

  • src [in] - JSON formatted string
  • jsonize [in, opt] - if true, objects( {} ) and arrays( [] ) are wrapped as JSON.object and JSON.array instances respectively. This is to compensate for AutoHotkey's non-distinction between these types and other AHK object type quirks. e.g.: In AutoHotkey, object keys are enumerated in alphabetical order not in the sequence in which they are created

.stringify()

serialize obj to a JSON formatted string

Syntax:

str := JSON.stringify( obj, [, indent := "" ] )

Return Value:

A JSON formatted string

Parameter(s):

  • obj [in] - AutoHotkey object. Non-standard AHK objects like COM, Func, FileObject, RegExMatchObject are not supported.
  • indent [in, opt] -if indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level. Blank( "" ) (the default) or 0 selects the most compact representation. Using a positive integer indent indents that many spaces per level. If indent is a string (such as "`t"), that string is used to indent each level. (I'm lazy, wording taken from Python docs)

Jxon.ahk (function)

Similar to the JSON class above just implemented as a function. Unlike JSON (class) above, this implementation provides reading from and writing to file. Works on both AutoHotkey v1.1 and v2.0


Jxon_Load()

Deserialize src (a JSON formatted string) to an AutoHotkey object

Syntax:

obj := Jxon_Load( src [ , object_base := "", array_base := "" ] )

Parameter(s):

  • src [in] - JSON formatted string or path to the file containing JSON formatted string.
  • object_base [in, opt] - an object to use as prototype for objects( {} ) created during parsing.
  • array_base [in, opt] - an object to use as prototype for arrays( [] ) created during parsing.

Jxon_Dump()

Serialize obj to a JSON formatted string

Syntax:

str := Jxon_Dump( obj [ , indent := "" ] )

Return Value:

A JSON formatted string.

Parameter(s):

  • obj [in] - this argument has the same meaning as in JSON.stringify()
  • indent [in, opt] - this argument has the same meaning as in JSON.stringify()

Jxon_Read()

Similar to Jxon_Load() except src is a path to the file containing a JSON document.

Syntax:

Jxon_Read( src [ , object_base := "", array_base := "" ] )

- - -

Jxon_Write()

Similar to Jxon_Dump() except output is written to dest. The number of bytes written is returned if successful.

Syntax:

bytes_written := Jxon_Write( obj , dest [ , indent := "" ] )

autohotkey-json's People

Contributors

cocobelgica avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.