Jay
  1. SilverStripe\VersionedAdmin\Controllers\CMSPageHistoryViewerController:
  2. class: SilverStripe\CMS\Controllers\CMSPageHistoryController
Mo

That way you can have some common logic for all objects you want to convert and manage the specific fields via a variable on the DataObject

👍 (1)
Mo

I do something similar, but I usally define a mapping (array) variable for each object then have a method that converts the mapping to an array/object

👍 (1)
Ed Linklater

of course if you just want every field you could do something like getQueriedDatabaseFields() in your jsonSerialize() method, but by using JsonSerializable it makes it that you don't have to think about it anywhere else, just json_encode the dataobject/datalist directly

🙏 (1) 👍 (1)
Ed Linklater

as it gives me complete control over which fields are and aren't included