p-json
json モジュールはJSONのパースとシリアライズ関数を提供します。
use p-json as jparse[str]
Section titled “parse[str]”JSON文字列をパースし、対応する値を返します。
use p-json as jconst data be j.parse[///{"name": "Purus", "version": 1}///]console.log[data.name] -- "Purus"stringify[val]
Section titled “stringify[val]”値をJSON文字列に変換します。
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]”値を整形されたJSON文字列に変換します。indent はインデントのスペース数を指定します(デフォルト: 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-- }