Hi,

I am trying to use json:transform-from-json(), and I get a weird
result on JSON object nodes retrieved from the database.  The
following script produces the expected result:

var j = require('/MarkLogic/json/json');
var obj = {'objects': [{'obj':{'id':'one'}},{'obj':{'id':'two'}}]};
j.transformFromJson(obj);

But if I change the array in the object to retrieve both objects from
the database:

var j = require('/MarkLogic/json/json');
var obj = {'objects': [fn.doc('/test/one.json'), fn.doc('/test/two.json')]};
j.transformFromJson(obj);

Then it serializes them both as strings:

<json type="object" xmlns="http://marklogic.com/xdmp/json/basic";>
   <objects type="array">
      <item type="string">{"obj":{"id":"one"}}</item>
      <item type="string">{"obj":{"id":"two"}}</item>
   </objects>
</json>

The following query inserts both documents:

declareUpdate();
xdmp.documentInsert('/test/one.json', { 'obj': {'id': 'one'} });
xdmp.documentInsert('/test/two.json', { 'obj': {'id': 'two'} });

I thought fn.doc() would return the object nodes, not a string
representing them.  Did I miss anything?

Regards,

-- 
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/
_______________________________________________
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to