🚀 Welcome to MDriven Learn –  Don’t miss the latest Release Notes.
OCLOperators ViewModelAsJSon

Returns the ViewModel content as a Json formatted string.

Naming Nodes

If you set the Presentation name of the ViewModel attribute, that name will be used instead of the ViewModel attribute name. This enables you to have, for example, "-" (dash) in the node name.


Example:

A ViewModel with:

  • CustomerName = "Sandra"
  • OrderAmount = 6000
  • Presentation Name of OrderAmount = order-amount


Using:

selfVM.ViewModelAsJson

Result:

{
  "CustomerName": "Sandra",
  "order-amount": 6000
}

See also: OCLOperators ViewModelAsXml to get the same information as XML.