Home page logo
/
Intro Reference Guide Book Install Guide
Download Changelog Zenmap GUI Docs
Bug Reports OS Detection Propaganda Related Projects
In the Movies In the News

Sponsors


Library json

Library methods for handling JSON data. It handles JSON encoding and decoding according to RFC 4627.

There is a test section at the bottom which shows some example parsing. If you want to parse JSON, you can test it by pasting sample JSON into the TESTS table and run the test method

There is a straightforward mapping between JSON and Lua data types. One exception is JSON NULL, which is not the same as Lua nil. (A better match for Lua nil is JavaScript undefined.) NULL values in JSON are represented by the special value json.NULL.

Author:
Martin Holst Swende (originally), David Fifield, Patrick Donnelly

Copyright© Same as Nmap--See http://nmap.org/book/man-legal.html

Source: http://nmap.org/svn/nselib/json.lua

Functions

generate (obj)

Creates json data from an object

make_array (t)

Makes a table be treated as a JSON Array when generating JSON

make_object (t)

Makes a table be treated as a JSON Object when generating JSON

parse (data)

Parses JSON data into a Lua object.

typeof (var)

Checks what JSON type a variable will be treated as when generating JSON



Functions

generate (obj)

Creates json data from an object

Parameters

  • obj: a table containing data

Return value:

a string containing valid json
make_array (t)

Makes a table be treated as a JSON Array when generating JSON

A table treated as an Array has all non-number indices ignored.

Parameters

  • t: a table to be treated as an array
make_object (t)

Makes a table be treated as a JSON Object when generating JSON

A table treated as an Object has all non-number indices ignored.

Parameters

  • t: a table to be treated as an object
parse (data)

Parses JSON data into a Lua object.

This is the method you probably want to use if you use this library from a script.

Parameters

  • data: a json string

Return values:

  1. status true if ok, false if bad
  2. an object representing the json, or error message
typeof (var)

Checks what JSON type a variable will be treated as when generating JSON

Parameters

  • var: a variable to inspect

Return value:

a string containing the JSON type. Valid values are "array", "object", "number", "string", "boolean", and "null"

Nmap Site Navigation

Intro Reference Guide Book Install Guide
Download Changelog Zenmap GUI Docs
Bug Reports OS Detection Propaganda Related Projects
In the Movies In the News
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]
AlienVault