Hi, Gnana: Just to add a few footnotes on the useful specifics David provides below....
MarkLogic does not store JSON natively. Instead, you can use a lossless conversion of your JSON data structure to and from XML. You can persist and index the XML representation of your data structure. As David notes, the REST API provides a facade that encapsulates the conversion. In other words, you can just send and receive documents using the "format=json" URI parameter or the application/json mime type with the Content-Type or Accept HTTP header. When defining range indexes, however, you need to inspect the persisted XML to find out the correct elements to index. In XQuery, besides manipulating the converted XML in the usual way, you can use the xdmp:from-json() function to convert a JSON string to in-memory map and array objects. While these can be serialized to XML, you get a more useful XML representation for indexing by using the REST facade or the transform capabilities that David explicates. Hoping that's useful, Erik Hennum ________________________________ From: general-boun...@developer.marklogic.com [general-boun...@developer.marklogic.com] on behalf of David Lee [david....@marklogic.com] Sent: Wednesday, June 26, 2013 6:28 AM To: MarkLogic Developer Discussion Subject: Re: [MarkLogic Dev General] using JSON and indexing and querying JSON Assuming you mean using Version 6 of MarkLogic. JSON documents can be loaded into MarkLogic in several ways. If you load using the REST or Java API's the JSON documents are converted to a "black box" XML format using this conversion http://docs.marklogic.com/json:transform-from-json Using the "basic" strategy. You can see what that looks like by either loading documents then inspecting them as XML , or you can run say in QConsole the examples given at the above link. Default indexing is done for the resultant XML. You can also add your own indexes and work directly on the data as XML but you must then be aware of what this "black box" format is and use XML indexing and queries. Alternatively if you stick to the Java API or REST layer you can make queries in JSON directly. Another approach (more advanced) is to make use of the "custom" strategy to convert JSON to XML and back, this requires more thought and effort but you have greater control over the transformation and can produce XML or JSON closer to or identical to what you want. ----------------------------------------------------------------------------- David Lee Lead Engineer MarkLogic Corporation d...@marklogic.com Phone: +1 812-482-5224 Cell: +1 812-630-7622 www.marklogic.com<http://www.marklogic.com/> From: general-boun...@developer.marklogic.com [mailto:general-boun...@developer.marklogic.com] On Behalf Of gnanaprakash.bodire...@cognizant.com Sent: Wednesday, June 26, 2013 9:24 AM To: general@developer.marklogic.com Subject: [MarkLogic Dev General] using JSON and indexing and querying JSON Hi I am just wondering if we could load only JSON documents into MarkLogic and then index the keys as we do for XML elements? (I know indexing is possible but my though Can we create indexes similar to XML elements range, path range indexes? Can we query the JSON similar to XQuery? Gnana(GP) Gnanaprakash Bodireddy | Sr. Associate – Projects | IME | Cognizant Technology Solutions. Address: Manyata Embassy Business Park, Outer Ring Road, Rachenahalli, Bangalore, Karnataka, Pin :560045 O: +91 (80) 66808000 extn: 502406| Mobile: +91 8197558899 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.
_______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general