🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators ViewModelAsJSon
Created by Lars.olofsson on 2019-03-28 · Last edited by Sandra.akech on 2025-12-12.

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.