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

Unable to pass numeric values as an object key. #79

Open
LIvvieLynn opened this issue Jun 23, 2021 · 4 comments · May be fixed by #115
Open

Unable to pass numeric values as an object key. #79

LIvvieLynn opened this issue Jun 23, 2021 · 4 comments · May be fixed by #115
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@LIvvieLynn
Copy link

There appears to currently be no way to use a numeric key for a dict variant.

I'm trying to add BlueZ manufacture data which requires the signature "a{qay}". E.g. {0xFFFF, [0x70, 0x74]}

When attempting to pass a variant of {0xFFFF, [0x70, 0x74]}, dbus-next converts it to { '65535': [ 112, 116 ] }. Where Object.keys converts 0xFFF to a string '65535'. Is there anyway to allow non-string keys for dict entries? (Possibly parsing strings for numeric signature types or allowing arrays in addition to objects. e.g. [[Key,Value],[Key,[Key,Value]]] for {Key:Value, Key:{Key:Value}}.)

Thanks

@Intellithings
Copy link

I'm having the same problem.
In fact, the problem is coming from JavaScript converting object numeric keys to string.

@acrisci
Copy link
Member

acrisci commented Jul 26, 2021

This shouldn't be a limitation of the library since marshalling and unmarshalling values always requires a signature that will indicate the keys are numeric. So the solution would be to parse strings for numeric signature types like you said. It shouldn't be a hard fix. Any help on this would be appreciated.

@acrisci acrisci added bug Something isn't working help wanted Extra attention is needed labels Jul 26, 2021
@Intellithings
Copy link

well, I see marshallers.js has checkInteger
if (typeof data !== 'number') we can try to parse int it instead of throwing exception. perhaps return something back.
in the 'q' switch case, we should convert data to int in case the check function fail.

@acrisci
Copy link
Member

acrisci commented Jul 26, 2021

Yeah that would be good.

@QuadratClown QuadratClown linked a pull request Nov 16, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants