TITLE ^

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

SYNOPSIS ^

 # generate a JSON representation of a PMC.
 $S0 = _json( $P0 )

 # generate a PMC from a JSON representation:
 $P1 = _json_to_pmc( "[1,2,3]" ) 
 #$P1 is now a array-like container PMC with three Integer elements.

 .end
 .include 'library/JSON.pir'

DESCRIPTION ^

PIR implementation of JSON

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.

(pmc) = _json_to_pmc(string)

Given a JSON string, return a PMC that represents that data.

string

Required. A JSON data string.

The following PMCs are used when unmarshalling a JSON string: ResizablePMCArray, Hash, String, Integer, Float, Boolean, Null.

TODO ^

  1. implement _jsan_to_pmc - Jerry Gay was rolling some PGE to do the heavy lifting here.
  2. Thunk a better way to deal with the maximum recursion depth exception (Or make it official)


parrot