Deactivated JSON Fields
Zesty.io now offers more control over the inclusion of deactivated fields in the toJSON output, both at the instance level and on a per-request basis.
Zesty.io has introduced a new setting in the Instance Settings called Include deactivated fields in toJSON output
. This setting allows you to control the behavior of the ?toJSON endpoints globally across your instance.
When this setting is turned on (default), all schema fields will be included in the toJSON output, even those that have been deactivated. This ensures that you have access to all the data associated with a content item, regardless of the field's active status.
If you prefer to exclude deactivated fields from the toJSON output, you can turn this setting off. When disabled, only active fields will be included in the rendered JSON object. This can be useful for reducing the size of the output and focusing on the most relevant data.
Configuring toJSON Behavior
- Go to "Settings" in the left sidebar
- Go to the "Developer"
- Click/Toggle "Include deactivated fields in toJSON output"
In addition to the global instance setting, Zesty.io also provides a way to control the inclusion of deactivated fields on a per-request basis. You can now use the optional GET parameter ?showDeactivated
to override the instance setting for individual requests.
To exclude deactivated fields from the toJSON output for a specific request, simply append
?showDeactivated=false
to the ?toJSON URL. For example:
https://www.mydomain.com/blog/my-article/?toJSON&showDeactivated=false
This parameter takes precedence over the instance setting, allowing you to customize the toJSON output according to your needs for each request.
By offering both a global instance setting and a per-request parameter, Zesty.io provides flexibility and control over the inclusion of deactivated fields in the toJSON output. This empowers developers to adapt the JSON representation of content items to their specific requirements, whether they need all the data or only the active fields.
Updated 2 months ago