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

Fields on Object with numeric properties returns empty array #29

Open
beaugunderson opened this issue Dec 7, 2023 · 1 comment
Open

Comments

@beaugunderson
Copy link

beaugunderson commented Dec 7, 2023

I am trying to store data in my registers using jsonDecode/jsonEncode. Once I decode my object I want to convert it to a Map by iterating over the object's keys. The only way I can see to do this is to use object.class.fields... but this seems to filter out numeric keys and the result is an empty array ([]). My object is keyed by weapon and chip ID, which are numeric. Is there an alternate way to get the list of keys in an object?

This is the data format I am using:

91547

@beaugunderson
Copy link
Author

A-ha! It is undocumented but from reading the code and testing it it's clear that object.keys() does what I want, I found it here:

if (member.equals("keys")) {
return Type.function(Type.ARRAY_STRING, new Type[0]);
}

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

1 participant