I've read about ML8's JSON constructors so I started rewriting my ML7
XQuery for better readabilty.

Below is my ML8 code (which I haven't tested yet) which has a for loop that
adds members to a JSON array.

My question is, is there another way (more akin to constructors) of adding
members to a JSON array other than calling json:array-push ?

Regards,
Danny


    *let **$main-array* := *array-node* { }
    *let* *$_* :=
              *for **$type* *in **$values*
              *let* *$type-name* := *helper:get-type-name*(*$chart-name*,
*$type*)
              *return*
                 *json:array-push* (*$main-array*, *object-node* { "name" :
$type-name,
                                                             "children" :
array-node {

    *object-node* { "name" : $type-name,

                  "id" : helper:get-clean-id ($type),

                  "size" : cts:frequency($type)

    }
                                                                          }
                                               }

                 )
    *let* *$main-object* := *object-node* { "name" : "flare", "children" :
$main-array }
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to