JSON
paket "JSON";
The JSON
package is used to work with JSON - JavaScript Object Notation. The package contains the following functions:
- objekatIzJSON
- JSONTekst
You will most likely need this package when working with an external API.
objekatIzJSON
The objekatIzJSON
function is used to parse a Bosscript object out of a provided JSON string.
- takes: str - JSON string
tekst
- returns: object parsed from
str
(objekat
) - special cases
- throws Exception if
str
is not a valid JSON string
- throws Exception if
var obj = objekatIzJSON('{"x": 1, "y": true, "z": "hello"}'); ispis(obj);
Output: {x: 1, y: tačno, z: "hello"}
JSONTekst
The JSONTekst
function is used to stringify a Bosscript object into a JSON string:
- takes: obj - object to be stringified
objekat
- returns: str - JSON string representation of
obj
(tekst
) - special cases: none
var str = JSONTekst({x: 1, y: tačno, z: "hello"}); ispis(str);
Output: {"x": 1, "y": true, "z": "hello"}