op.prop

op.prop(
   name as String,
   content as String
) as propertyDef

Summary

This function specifies the key expression and value content for a JSON property of a JSON object contructed by the op.jsonObject function.

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

Example


const op = require('/MarkLogic/optic');

op.fromView('main', 'employees')
   .select(op.as('Employee', op.jsonDocument(
	              op.jsonObject([
	                  op.prop('Position', op.jsonString(op.col('Position'))),
	                  op.prop('ID', op.jsonArray([
	                      op.jsonNumber(op.col('EmployeeID'))
	                      ]))
	                  ])
	              )))
  .result();
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy