Hi, Manoj: Because the signature requires a search:snippet return and the function implementation returns text, I'm surprised it doesn't throw an error. Regardless, I think I know what you're running into.
The REST API converts the search:response XML structure returned by the Search API to JSON. To convert a custom snippet to JSON, the custom snippetter must emit an XML structure with a known mapping to JSON. So, either the search:snippet element or a list of search:snippet/search:match elements (but not both) must contain the equivalent of the XML output from the json:transform-from-json() function with the default configuration. (That is, elements in the "http://marklogic.com/xdmp/json/basic" namespace with type annotation attributes -- the same vocabulary that used when persisting JSON documents in the database.) The search:snippet must contain a complete JSON object or array expressed with that XML vocabulary. In 6.0, the REST API assumed that text was JSON, but that behaviour was a bug. There are many cases where text must be quoted as a string instead of interleaved as JSON. The fix for that bug, however, created an unfortunate backward incompatibility in cases such as yours. Because the revision will be to an XML-to-XML transform, our hope is that the revision will be straightforward after you become familiar the vocabulary (possibly by transforming a few samples from JSON using the default transform). Hoping that clarifies, Erik Hennum ________________________________ From: [email protected] [[email protected]] on behalf of manoj viswanadha [[email protected]] Sent: Monday, July 21, 2014 11:17 PM To: MarkLogic Developer Discussion Subject: Re: [MarkLogic Dev General] JSON issue with REST API Hi Erik, Thanks for your quick resposne. Please find the attached transformation file which i am using to tranform xml to json response. As i already mentioned same code working good with ML-6 but its not coming as pure json in ML-7. Thanks, Manoj. On Mon, Jul 21, 2014 at 6:28 PM, Erik Hennum <[email protected]<mailto:[email protected]>> wrote: Hi, Manoj: You might get a more useful response if you provide the transform code. Assuming the transform is in XQuery, you can quote with either single or double quotes, so it might be convenient to use single quotes to wrap the string with embedded quotes (as in '{"key":"value"}'). Alternatives include using the XML " entity or doubling the double quote, but that would be less readable. Hoping that helps, Erik Hennum ________________________________ From: [email protected]<mailto:[email protected]> [[email protected]<mailto:[email protected]>] on behalf of manoj viswanadha [[email protected]<mailto:[email protected]>] Sent: Monday, July 21, 2014 4:14 AM To: MarkLogic Developer Discussion Subject: [MarkLogic Dev General] JSON issue with REST API Hi all, I am facing some issue with json response using ML-7 REST API. I am using tranformations using REST API options to convert xml to json. In ML-6 i am able the get the pure json response but in ML-7 i am getting JSON response as string. Because of that double quotes (" ") its not coming as perfect json response. Is there any way to escape these double quotes in ML-7. expected-result: {name : "testing"} result in ML-7 rest API: "{name:"testing"}" Thanks, Manoj Viswanadha Cognizant Technology Solutions Hyderabad. _______________________________________________ General mailing list [email protected]<mailto:[email protected]> http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
