All the data exported is formatted with a string. Enclosed with quotes.
I’d like excluded_id to be numeric. The current state is the following.
[ { "pending_id": "1234", "excluded_id": "111", }]
I’d like the format to be the following.
[ { "pending_id": 1234, "excluded_id": 111, }]
The JSON service is implemented as a REST plugin. The normalizer is the following.
use DrupalserializationNormalizerNormalizerBase; class CBIBondTableDataNormalizer extends NormalizerBase { protected $supportedInterfaceOrClass = 'Drupalcbi_dms_datadatamodelCBIBondTableResultData'; public function normalize($object, $format = NULL, array $context = []) { return $object->normalize(); } }
With the normalizer.
class MyTableResultData implements MyTableResultType { public $row = []; public function __construct() {} public function addSqlResult($object) { $result = new CBIBondTableResult($object); $this->row[] = $result; } public function normalize() { $output = []; foreach ($this->row as $currentRow) { $output[] = (object) $currentRow; } return $output; } }
I’ve tried setting the type in MyTableResultData
.
public int $PendingID;
This doesn’t work as PHP 7 doesn’t allow something to be an integer or null.