Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid integer string convertion from PHP serialized .msgpack #226

Open
RemiLelaidier opened this issue Apr 14, 2023 · 1 comment
Open

Comments

@RemiLelaidier
Copy link

Hi,

I am currently working on a project where I serialize JSON objects using the php library msgpack-php, but when I try to deserialize these objects using the javascript library msgpack-javascript, my integers are truncated.

PHP :

$data = [
    '7355750935770677725' => "test",
];

$msg = msgpack_pack($data);

...

JS :

import { decode } from '@msgpack/msgpack';

const decoded = decode(entry);

console.log(decoded)

Result :

{  '7355750935770677000': 'test'  }

As you can see the last three digits of my integer are set to 0.

This seems to be an interoperability problem between the php library and Node.js

@BerndAmend
Copy link

Your number is bigger than Number.MAX_SAFE_INTEGER and can therefore not be processed as a JavaScript number.
You may need to have a look at the JavaScripts BigInt type and the DecoderOption useBigInt64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants