-
Notifications
You must be signed in to change notification settings - Fork 64
Message pack improperly serializes maps with numerical indexes #32
Copy link
Copy link
Open
Description
When emitting a map of data that uses non-sequential numerical indexes, e.g.:
$data = [
"3" => "foo",
"7" => "bar"
];
$emitter = new SocketIO\Emitter();
$emitter->emit('event', $data);
The data is serialized, emitted, and received as an array, e.g.:
{
"0": "foo",
"1": "bar"
}
The only way around this right now is to add a non-numerical key into the map, e.g.:
$data = [
"3" => "foo",
"7" => "bar",
"hack" => true
];
$emitter->emit('event', $data);
The reason this is happening is because in this file (https://github.com/rase-/socket.io-php-emitter/blob/master/src/msgpack_pack.php#L79) starting at line 79, the code is converting the data to an array if all keys in the data are ints, regardless of if the keys are sequential or not.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels