toJSON()method has two optional parameters, giving the user control over hydration level and the inclusion of metadata. This is achieved with the following syntax:
depthis an integer for hydration depth, max depth is 5
showMetasupports a boolean value of true or false.
trueprovides all meta, routing, zuid details, and locale details.
falseprovides only content.
showMeta,are optional. The default output of the method, without specification, will include meta data and a hydration depth level of 2.
toJSON()method can be used in a variety of ways to format the desired content and the URL routing location it will be rendered from. Below details how this can be accomplished in three different ways:
thisinside of the Item associated View will access the corresponding Item's content. The Parsley keyword
thiscan only be used on a Content Model generated View, as it points to the connected item. For example:
eachloops to render a JSON object of each item. Inside the
eachloop, filters can be applied by adding Parsley if or where conditionals as well to only output desired objects. For example: