Make JSON Document Function

$MakeJSON generates complete JSON document based on passed structure. The function call should contain a list of item definitions separated by comma. Each definition must be closed by pair of '(' and ')' for objects or '[' and ']' for arrays. Each item definition is exact same as $MakeJSONItem call.

There are two types of items: root items and references. The function generates values for the first and uses as a reference only for the second. The reference item must be encoded as @(...) and the root one as (...).


  1. $MakeJSON((1,A,,[3],,0),(2,B,,[4]),@[3,,,($Rint()),=5],@(4,CityN,1,($Lib(Cities)),=2)) will generate a document like {"A":[100,43012,7,6578,332],"B":{"City4":"Madrid","City6":"Paris"}}
    (1,A,,3) creates an object with name "A" with reference to array defined by ID #3. (2,B,,4) produces an object with name "B" that references to object #4.
  2. $MakeJSON((1,A,,[2,3]),@(2,B,,(XXXX),,0),@(3,C,,($Rint()),,0)) generates A with two depended (child) items like {"A":{"B":"874D","C":30976}}