Skip to content

The JSON Standard Library

C272 edited this page Aug 30, 2019 · 4 revisions

Facilitates the serializing and deserializing of Algo to JSON (JavaScript Object Notation).


json.make(val)

Serializes an Algo object or list to JSON, providing none of the object members are unsupported types. The list of supported types is as follows:

  • Object
  • List
  • String
  • Integer
  • Float
  • Rational
  • Boolean
  • Null

Parameters:

Name Description
val The object or list to serialize to JSON.

Usage:

let obj = object 
{
    let x = 3;
    let y = "example";
    let z = [1, 2];
}

let someJSON = json.make(obj); //{ x:3, y:"example", z:[1, 2]}

json.parse(str)

Parses a JSON string to an Algo object.

Parameters:

Name Description
str The JSON string to parse to Algo object.

Usage:

let x = json.parse("{ x: 3 }");
//x has one property, x, that has value 3.