Loading TOC...

MarkLogic Server 11.0 Product Documentation
op:prop

op:prop(
   $name as item(),
   $value as item()
) as map:map

Summary

This function specifies the key expression and value content for a JSON property of a JSON object constructed by the op:json-object function.

Parameters
$name The key expression. This must evaluate to a string.
$value The value content. This must be exactly one JSON node expression.

Example

xquery version "1.0-ml";

import module namespace op="http://marklogic.com/optic"
     at "/MarkLogic/optic.xqy";

op:from-view("main", "employees")
   => op:select(op:as("Employee", op:json-document(
	                 op:json-object((
	                    op:prop("Position", op:json-string(op:col("Position"))),
	                    op:prop("ID", op:json-array(
	                        op:json-number(op:col("EmployeeID"))
	                    ))
	                 ))
	  )))
   => op:result()

  

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