public function toFlattenedJSON($id)
{
$signature = $this->getSignature($id);
$data = [];
$values = ['payload' => $this->getEncodedPayload($signature), 'protected' => $signature->getEncodedProtectedHeaders(), 'header' => $signature->getHeaders()];
foreach ($values as $key => $value) {
if (!empty($value)) {
$data[$key] = $value;
}
}
$data['signature'] = Base64Url::encode($signature->getSignature());
return json_encode($data);
}