[MarkLogic Dev General] json:transform-to-json() with custom configuration is suppressing some content in XML to JSON transformation

Indrajeet Verma indrajeet.verma at gmail.com
Sat Jan 2 10:15:22 PST 2016


Hi,

I am using json:transform-to-json() function to convert XML node to json
however for a nested xml node and with custom configuration, this function
is suppressing some content.

Could you please suggest where I am doing mistake or this is not the right
conversion (json is not fit for mixed content )?

import module namespace json = "http://marklogic.com/xdmp/json"
    at "/MarkLogic/json/json.xqy";

let $node := <p>This is my test data <i>this should be italic</i> sample
content</p>
let $custom :=
    let $config := json:config("custom")
    let $_ := map:put( $config, "whitespace", "ignore" )
    return $config
  return
    json:transform-to-json( $node, $custom )


Result-

{
"p":
{
"i": "this should be italic",
"_value": " sample content"
}
}


import module namespace json = "http://marklogic.com/xdmp/json"
    at "/MarkLogic/json/json.xqy";

let $node := <p>This is my test data <i>this should be italic</i> sample
content</p>
return
    json:transform-to-json( $node, json:config("full") )

Result-

{
"p":
{
"_children":
[
"This is my test data ",
{
"i":
{
"_children":
[
"this should be italic"
]
}
}
,
" sample content"
]
}
}

Regards,
Indrajeet
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20160102/5c287698/attachment.html 


More information about the General mailing list