leekscript icon indicating copy to clipboard operation
leekscript copied to clipboard

Fields on Object with numeric properties returns empty array

Open beaugunderson opened this issue 2 years ago • 1 comments

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 avatar Dec 07 '23 02:12 beaugunderson

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:

https://github.com/leek-wars/leekscript/blob/f0c085341338b06913df8cfa4ab9bb51602ef569/src/main/java/leekscript/common/ObjectType.java#L11-L13

beaugunderson avatar Dec 07 '23 03:12 beaugunderson