json:object is the in-memory representation of maps used for json.
The only difference between map:map and json:object is that the keys are 
ordered (which actually is not something JSON guarentees ... but we do).
Your "magic function" is xdmp:to-json().

You dont do a transformation on json:object  TO JSON ... its already in the 
form needed ...  You can turn it into a JSON string using  xdmp:to-json() but 
thats not a transformation.
Transformations occur between XML <-> JSON

Did that answer your question ?



-----------------------------------------------------------------------------
David Lee
Lead Engineer
MarkLogic Corporation
[email protected]
Phone: +1 812-482-5224
Cell:  +1 812-630-7622
www.marklogic.com<http://www.marklogic.com/>


From: [email protected] 
[mailto:[email protected]] On Behalf Of Steve Spigarelli
Sent: Monday, July 22, 2013 2:39 PM
To: [email protected]
Subject: [MarkLogic Dev General] json:object

I'm having a difficult time understanding what good the json:object() function 
is. From what I can tell after using it, it is a specialized map:map object. I 
have tried using json:transform-to-json on the object but the transform 
function doesn't like that.

So, what is the proper way to create a json:object and receive back the actual 
JSON string?

For example:

let $json-obj := json:object()
let $_ := map:put($json-obj, "key", "value")

return magic-function($json-obj) which would return {"key": "value"}

What I get instead by calling json:transform-to-json($json-obj) is an invalid 
coercion error. Even wrapping the object and passing the node doesn't work.

Any ideas? Has anyone actually used this function? From the comments in the 
documentation it doesn't have many comments. 
(http://docs.marklogic.com/json:transform-to-json)

--
Steve
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to