GithubHelp home page GithubHelp logo

ahk.v1-2.json's Introduction

JSON.ahk

Works on both v1 and v2 of AutoHotkey


Installation

In a terminal or command line navigated to your project folder:

npm install json.ahk

In your code only export.ahk needs to be included:

#Include %A_ScriptDir%\node_modules\json.ahk\export.ahk

JSON.stringify([1, 2, 3])
; => "[1, 2, 3]"

JSON.parse("[1, 2, 3]")
; => [1, 2, 3]

You may also review or copy the library from ./export.ahk on GitHub; #Incude as you would normally if manually downloading.

API

.parse()

Parses a JSON string into a value.

Syntax:
value := JSON.parse(string [, reviver ])
Return Value:

value (object, string, number)

Parameter(s):
  • string - JSON formatted string
  • reviver [optional] - function object, prescribes how the value originally produced by parsing is transformed, before being returned. Similar to JavaScript's JSON.parse() reviver parameter
Example:
JSON.parse("[1, 2, 3]")
; => [1, 2, 3]

.stringify()

Converts a value into a JSON string.

Syntax:
str := JSON.stringify(value, [, replacer, space ])
Return Value:

A JSON formatted string

Parameter(s):
  • value - (object, string, number)
  • replacer [optional] - function object, alters the behavior of the stringification process. Similar to JavaScript's JSON.stringify() replacer parameter
  • space [optional] -if space 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 space indents that many spaces per level, this number is capped at 10 if it's larger than that. If space is a string (such as "`t"), the string (or the first 10 characters of the string, if it's longer than that) is used to indent each level
Example:
JSON.stringify([1, 2, 3])
; => "[1, 2, 3]"

.test()

tests if a string is a valid json string or not.

Syntax:
JSON.test(string)
Return Value:

true if the string is interpreted as valid json, else false

Parameter(s):
  • string - the string value to be tested for validity
Example:
JSON.test("[1, 2, 3]")
; => true

JSON.test([1, 2, 3]) ; an object
; => false

JSON.test("")
; => false

ahk.v1-2.json's People

Contributors

cocobelgica avatar chunjee avatar g33kdude avatar pa-0 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.