cogGet the properties of an object attached to a page as JSON
Developed by

Fawad Ali

0 Votes
LicenseGNU Lesser General Public License 2.1


Suppose we have an object of class XWiki.StyleSheetExtension and we want to get all of the properties in JSON.
Here is how we do it.


## Get the normal object
#set ($obj = $doc.getObject('XWiki.StyleSheetExtension'))

## Get the XWiki BaseObject from the normal object
#set ($baseObj = $obj.getXWikiObject())

## Get the Map of the object properties
#set ($objMap = $baseObj.getCustomMappingMap())

## Now that we have the Map, we can simply convert it to JSON using $jsontool
#set ($objJSON = $jsontool.serialize($objMap))

## Output the JSON


Make sure to have an object of type XWiki.StyleSheetExtension attached to the page

Prerequisites & Installation Instructions

Copy the code snippet to a page and save it.

Created by Fawad Ali on 2019/05/29 19:50

Get Connected