-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
21 lines (16 loc) · 806 Bytes
/
Copy pathindex.php
File metadata and controls
21 lines (16 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
require_once 'vendor/autoload.php';
$message = new \Main\Event([
'date' => date('Ymd'),
'time' => date('His'),
'country' => 'Portugal',
'idLanguage' => 555,
'siteHostName' => 'google.com',
'idAdvertiser' => 658468435,
]);
$jsonData = $message->serializeToJsonString(); // strlen($jsonData) = 122 bytes {"date":20241001,"time":141225,"country":"Portugal","idLanguage":555,"siteHostName":"google.com","idAdvertiser":658468435}
$binaryData = $message->serializeToString(); // strlen($binaryData) = 40 bytes ....
$dataStream = new \Google\Protobuf\Internal\CodedInputStream($binaryData);
$restoredFromBin = new \Main\Event(null);
$restoredFromBin->parseFromStream($dataStream);
var_dump($restoredFromBin->serializeToJsonString() === $jsonData); // true