Macaulay2 » Documentation
Packages » JSON :: JSON
next | previous | forward | backward | up | index | toc

JSON -- JSON encoding and decoding

Description

JSON (JavaScript Object Notation) is a common data interchange format. This package provides two methods, toJSON and fromJSON, for converting Macaulay2 things to valid JSON data and vice versa.

i1 : toJSON {hashTable{"foo" => "bar"}, 1, 3.14159, true, false, nil}

o1 = [{"foo": "bar"}, 1, 3.14159, true, false, null]
i2 : fromJSON oo

o2 = {HashTable{"foo" => bar}, 1, 3.14159, true, false, nil}

o2 : List

Author

Version

This documentation describes version 0.4 of JSON.

Citation

If you have used this package in your research, please cite it as follows:

@misc{JSONSource,
  title = {{JSON: JSON encoding and decoding. Version~0.4}},
  author = {Doug Torrance},
  howpublished = {A \emph{Macaulay2} package available at
    \url{https://github.com/Macaulay2/M2/tree/master/M2/Macaulay2/packages}}
}

Exports

  • Functions and commands
    • fromJSON -- decode JSON data into Macaulay2 things
    • toJSON -- encode Macaulay2 things as JSON data
  • Methods
    • fromJSON(File) -- see fromJSON -- decode JSON data into Macaulay2 things
    • fromJSON(String) -- see fromJSON -- decode JSON data into Macaulay2 things
    • toJSON(Boolean) -- see toJSON -- encode Macaulay2 things as JSON data
    • toJSON(HashTable) -- see toJSON -- encode Macaulay2 things as JSON data
    • toJSON(Hypertext) -- see toJSON -- encode Macaulay2 things as JSON data
    • toJSON(MutableHashTable) -- see toJSON -- encode Macaulay2 things as JSON data
    • toJSON(Nothing) -- see toJSON -- encode Macaulay2 things as JSON data
    • toJSON(Number) -- see toJSON -- encode Macaulay2 things as JSON data
    • toJSON(RR) -- see toJSON -- encode Macaulay2 things as JSON data
    • toJSON(String) -- see toJSON -- encode Macaulay2 things as JSON data
    • toJSON(Symbol) -- see toJSON -- encode Macaulay2 things as JSON data
    • toJSON(Thing) -- see toJSON -- encode Macaulay2 things as JSON data
    • toJSON(VisibleList) -- see toJSON -- encode Macaulay2 things as JSON data
    • toJSON(ZZ) -- see toJSON -- encode Macaulay2 things as JSON data
  • Symbols
    • IndentLevel (missing documentation)
    • nil -- a symbol a parser may return to indicate acceptance of the empty string of tokens
    • Indent -- see toJSON -- encode Macaulay2 things as JSON data
    • NameSeparator -- see toJSON -- encode Macaulay2 things as JSON data
    • ValueSeparator -- see toJSON -- encode Macaulay2 things as JSON data

For the programmer

The object JSON is a package, defined in JSON.m2, with auxiliary files in JSON/.


The source of this document is in JSON.m2:216:0.