[MarkLogic Dev General] Parsing json query

David Lee David.Lee at marklogic.com
Wed Oct 9 04:36:33 PDT 2013

the trick here is that the document is in a namespace so you need to use namespace enabled xpath.
For a larger docment especially if you have many documents stored in the DB you may get better results by being
more precise and declaring the namespace explicitly in your search such as

declare namespace j="http://marklogic.com/xdmp/json/basic";


David Lee
Lead Engineer
MarkLogic Corporation
dlee at marklogic.com
Phone: +1 812-482-5224
Cell:  +1 812-630-7622

From: general-bounces at developer.marklogic.com [mailto:general-bounces at developer.marklogic.com] On Behalf Of ASIT.NAUTIYAL at cognizant.com
Sent: Wednesday, October 09, 2013 7:23 AM
To: sini.isonline at gmail.com
Cc: general at developer.marklogic.com
Subject: Re: [MarkLogic Dev General] Parsing json query

Hi Sini,

Please try below code


Asit Nautiyal

From: general-bounces at developer.marklogic.com [mailto:general-bounces at developer.marklogic.com] On Behalf Of sini narayanan
Sent: Wednesday, October 09, 2013 4:37 PM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] Parsing json query

Hi All,

I have a json query string and I performed json:transform-from-json($json-query). I get the below output.

<json type="object" xmlns="http://marklogic.com/xdmp/json/basic">
  <query type="object">
    <and-query type="object">
      <queries type="array">
            <json type="object">
             <range-constraint-query type="object">
               <constraint-name type="string">country</constraint-name>
               <value type="array">
                 <item type="string">FRA</item>
            <json type="object">
             <range-constraint-query type="object">
               <constraint-name type="string">TravelType</constraint-name>
               <value type="array">
                 <item type="string">TOURISM</item>

How do I traverse through the output xml to get each constraint-name node.
I tried normal xpath on this output json:transform-from-json($json-query)//constraint-name. But this doesnot work.

Please help.

This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20131009/e620bcc1/attachment.html 

More information about the General mailing list