p-json
The json module provides JSON parsing and serialization functions.
use p-json as jFunctions
Section titled “Functions”parse[str]
Section titled “parse[str]”Parses a JSON string and returns the corresponding value.
use p-json as jconst data be j.parse[///{"name": "Purus", "version": 1}///]console.log[data.name] -- "Purus"stringify[val]
Section titled “stringify[val]”Converts a value to a JSON string.
use p-json as jconst obj be [name be ///Purus///, version be 1]const text be j.stringify[obj]console.log[text] -- {"name":"Purus","version":1}prettify[val; indent]
Section titled “prettify[val; indent]”Converts a value to a pretty-printed JSON string. The indent parameter specifies the number of spaces (default: 2).
use p-json as jconst obj be [name be ///Purus///, version be 1]console.log[j.prettify[obj]]-- {-- "name": "Purus",-- "version": 1-- }
console.log[j.prettify[obj; 4]]-- {-- "name": "Purus",-- "version": 1-- }