Thank you Eric and David for your response however our system is working fine in ML6 and details are,
Same I wanted to achieve in ML8 without changing in UI and other search API that are being used for retrieval. Input request in body via roxy, { "docTitle": "histories: Search for apple", "type": "Search", "searchParameter": { "page": 1, "pageLength": 10, "queryText": "apple AND microsoft", "contentCollection": "All Content" } } Output that is being saved in ML, XML document <http://localhost:8000/qconsole/#> <?xml version="1.0" encoding="UTF-8"?> <resource wk-pid="HIS-954e3f8f-2bbb-e79b-3747-7480b73db65b"> <docType> Histories </docType> <docTitle> histories: Search for apple </docTitle> <ownerId> USR-2fe944cc-013e-5b5a-0dba-7e98c3ffab00 </ownerId> <created> 2015-05-04T17:13:40.126+05:30 </created> <modified> 2015-05-04T17:13:40.126+05:30 </modified> <shared> </shared> <parameter> <type> Search </type> </parameter> <json type="object" xmlns="http://marklogic.com/json"> <type> Search </type> <searchParameter> <page> 1 </page> <pageLength> 10 </pageLength> <queryText> Apple AND microsoft </queryText> <contentCollection> All Content </contentCollection> </searchParameter> </json> </resource> On Mon, May 4, 2015 at 7:36 PM, David Lee <david....@marklogic.com> wrote: > Erik addressed the most likely issue/question. > > As a follow-up , for clarification - > > your 2 examples are fundamentally different use cases of > json:transform-to-xml() > > The first use (without the $config) is intended *only* for the pre-V8 > use case of transforming > > arbitrary JSON into a 'black box' XML format with 100% fidelity. While > it is a fairly readable format, > > Its not intended to be used directly - it is an implementation used by V7 > before we had native JSON data types in the database. > > It is maintained for backwards compatibility for that use case only (if > you have existing data in V7 format). > > > > The second example (with the 'custom' strategy and a $config) is not > intended as a refinement or otherwise > > replacement for the first case. Its designed to allow for custom > transformations between JSON and XML - > > possibly bi-directionally - at the expense of losing 100% fidelity. > Many of these use cases are no longer necessary in V8 > > due to native support for JSON directly. > > > > It *can* be used as you have done - it should not be confused with the > first case ( making any modifications > > at all to the 'basic' strategy transformation produces XML which will > break any code expecting the V7 internal format), > > and I don't recommend it for API's that have a JSON interface - its much > better to use that directly if possible. > For API's that accept either JSON or XML - the formats for both are well > defined - but the transformation between those formats > can be very complex to get 100% right. So if you have JSON and using an > API that accepts JSON - its much easier and better > > (and more efficient) to not attempt to transform it to XML. > > > > > > > > > ----------------------------------------------------------------------------- > > David Lee > Lead Engineer > *Mark**Logic* Corporation > d...@marklogic.com > Phone: +1 812-482-5224 > > Cell: +1 812-630-7622 > www.marklogic.com > > > > *From:* general-boun...@developer.marklogic.com [mailto: > general-boun...@developer.marklogic.com] *On Behalf Of *Erik Hennum > *Sent:* Monday, May 04, 2015 9:16 AM > *To:* MarkLogic Developer Discussion > *Subject:* Re: [MarkLogic Dev General] json namespace changes in > json:transform-from-json($input) > > > > Hi, Indrajeet: > > In MarkLogic 8, you would typically store JSON directly as native JSON and > not converted to XML. The direct approach will improve performance and > maintainability. > > In the particular case, xdmp:unquote() will turn the input string into a > JSON document that can be inserted into the database. > > The particular case looks like the input to a search request. Is there is > a specific reason it must be encoded as XML? > > > > Erik Hennum > ------------------------------ > > *From:* general-boun...@developer.marklogic.com [ > general-boun...@developer.marklogic.com] on behalf of Indrajeet Verma [ > indrajeet.ve...@gmail.com] > *Sent:* Monday, May 04, 2015 6:00 AM > *To:* MarkLogic Developer Discussion > *Subject:* [MarkLogic Dev General] json namespace changes in > json:transform-from-json($input) > > Hi, > > > > While upgrading ML6 to ML8, I needed to modify the JSON format and I did > it based on my understanding on ML8 JSON handling however my senior is not > convince with this solution so wanted to know if my approach is not best > fit and could be better solution. > > > > Please someone take a look on my code and suggest any better solution? > > > > let $input := '{"docTitle":"histories: Search for apple", "type":"Search", > "searchParameter":{"page":1, "pageLength":10}}' > > > > When I am using json:transform-from-json($input), getting below output > with namespace "http://marklogic.com/xdmp/json/basic" > > <json type="object" xmlns="http://marklogic.com/xdmp/json/basic"> > > <docTitle type="string"> > > histories: Search for apple > > </docTitle> > > <type type="string"> > > Search > > </type> > > <searchParameter type="object"> > > <page type="number"> > > 1 > > </page> > > <pageLength type="number"> > > 10 > > </pageLength> > > </searchParameter> > > </json> > > > > However I wanted the results with the namespace " > http://marklogic.com/json" so I have coded like below, > > > > let $custom := > > let $config := jsonl:config("custom") > > return > > ( > > map:put($config, "element-namespace", " > http://marklogic.com/json"), > > $config > > ) > > let $json := try{ (jsonl:transform-from-json($input, $custom)) } catch > ($e) {()} > > let $json := <json type="object" xmlns="http://marklogic.com/json > ">{$json}</json> > > return $json > > > > *output:* > > <json type="object" xmlns="http://marklogic.com/json"> > > <docTitle> > > histories: Search for apple > > </docTitle> > > <type> > > Search > > </type> > > <searchParameter> > > <page> > > 1 > > </page> > > <pageLength> > > 10 > > </pageLength> > > </searchParameter> > > </json> > > > > Regards, > > Indy > > _______________________________________________ > General mailing list > General@developer.marklogic.com > Manage your subscription at: > http://developer.marklogic.com/mailman/listinfo/general > >
_______________________________________________ General mailing list General@developer.marklogic.com Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general