🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators ViewModelAsJSon
This page was created by Lars.olofsson on 2019-03-28. Last edited by 62.169.16.147 on 2026-09-12.

Returns the ViewModel content as a Json formatted string.

Naming Nodes[edit source]

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.