I’m using a class inhereting OCP\AppFramework\Db\QBMapper to connect my items to the database. In my item class, I also have a jsonSerialize function to serialise the item e.g. for the API into json code.
Now is the problem, that some database columns are too long. But they have exectly the name, how I need to name the property within the API (specified by 3rd Party).
How can I solve this problem? Having shorter column name in the DB, but the long property name in the API?
e.g. in the schema the (too long) column is defined as
$table->addColumn('application_installation_enabled', 'boolean', [
'default' => false,
'notnull' => false,
]);
in the entity class I have the following code, resulting in the desired API json name ‘applicationInstallationEnabled’ in the Policy API endpoint:
class Policy extends Entity implements JsonSerializable {
protected $accountCreationEnabled;
public function jsonSerialize() {
return [
'applicationInstallationEnabled' => $this->applicationInstallationEnabled,
}
}