Loading TOC...

MarkLogic Server 11.0 Product Documentation
es.instanceJsonFromDocument

es.instanceJsonFromDocument(
   entity-document as Node
) as objectNode()

Summary

This function is deprecated and will be removed in a future release.
Extract an entity instance from its envelope document, as JSON.

Parameters
entity-document A document that contains canonical entity instance(s).

Usage Notes

Use this function to extract the canonical instance from an envelope document and return it as JSON.

See Also

Example

/* Assume /es-gs/env/1234.xml is an envelope document with
 * the following contents:

  <es:envelope xmlns:es="http://marklogic.com/entity-services">
    <es:instance>
      <es:info>
        <es:title>Person</es:title>
        <es:version>0.0.1</es:version>
      </es:info>
      <Person>
        <id>1234</id>
        <firstName>George</firstName>
        <lastName>Washington</lastName>
        <fullName>George Washington</fullName>
      </Person>
    </es:instance>
    <es:attachments>
      <person>
        <pid>1234</pid>
        <first>George</first>
        <last>Washington</last>
      </person>
    </es:attachments>
  </es:envelope>
*/

const es = require('/MarkLogic/entity-services/entity-services');
fn.head(
  es.instanceJsonFromDocument(cts.doc('/es-gs/env/1234.xml'))
);

/* Returns the following, as a JSON object node:
  { "Person": {
      "id":1234, 
      "firstName":"George", 
      "lastName":"Washington", 
      "fullName":"George Washington"
  } }
*/
  

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.