TITLE ^

JSON.pir - PIR implementation of JSON data interchange format.

SYNOPSIS ^

Use the _json method to generate a JSON representation of a PMC.

 .include 'library/JSON.pir'
 $S0 = _json( $P0 )

To generate a PMC from a JSON string, see "json/JSON.pir" in compilers.

FUNCTIONS ^

This library provides the following functions:

(string) = _json(pmc, ?pretty )

Convert a PMC to a JSON-serialized string. Note: If you pass in a cyclic structure, JSON will eventually throw a maximum recursion depth exception.

pmc

Required. The PMC to dump.

pretty

Optional. Boolean: If true, then the generated string will be very readable for humans. Defaults to false, which will generate the most compact string possible.

TODO ^

  1. Thunk a better way to deal with the maximum recursion depth exception (Or make it official)


parrot