-
Notifications
You must be signed in to change notification settings - Fork 132
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
Exporting array elements to JSON misses out indexes and loses data #158
Comments
Im sorry I don't understand how similar fields would overwrite each other if Properties is a List |
what about this? |
I'll have to try out the patch to figure out what the effect is. But let me try to explain the issue a little better:
The two JSON examples in the original post show what it currently looks like (missing a lot of data) and what my prototype looks like. |
Right. JSON readers typically don't like this, but I understand it's quite a grey area in the specs. The bigger problem is that these overrides are usually sparse, so we still need to know the indexes for each entry. If you look at my example it overrides the elements at indexes 0, 1, 2, 4, 7 but leaves the others to be inherited from the parent. Your current array solution doesn't contain that information. Of course the array could have nulls or something, but it would be neater as a map with the key being the index. In my original post I mentioned this, but was worried about breaking existing readers. If this isn't an issue, a map would be the perfect result. Thanks for taking time to look at this! |
I believe coldino is saying that a more accurate representation of the property would be: {
"MaxStatusValues": [
650,
500,
500,
null,
6000,
null,
null,
550
]
} and a more consise, but possibly breaking form would be: {
"MaxStatusValues": {
"0": 650,
"1": 500,
"2": 500,
"4": 6000,
"7": 550
}
} another verbose but backward compatible solution could add a non-standard json property to hold the array indices {
"Properties": {
"MaxStatusValues": [
650,
500,
500,
6000,
550
]
},
"__PropertyArrayIndex": {
"MaxStatusValues": [
0,
1,
2,
4,
7
]
}
} |
Well, the core issue is that the indexes are not exported, yes, but actually both forms are format-breaking. As that is the case, the map is by far the preferred. |
the main problem for implementing a format breaking solution is knowing the difference between an indexed prop and a non-indexed prop on UE4 games so the viable option as of now would be the forked one ig? |
Yup it's a dilemma for sure - that's why I leave it up to you really as you know much more about the project and wider ecosystem than me. If you want to go with the fork option I can raise a PR but as it's only one line feel free to just do it if takes less of your time. |
It seems to be currently impossible to correctly/fully export assets that override individually indexed array elements.
An example:

All of these similar fields (with different indexes) would overwrite each other so only a single field remains in the JSON:
Fixing this is a little problematic because most "good" solutions break with the existing format.
The compromise solution I'm testing in a fork (0367620) is to continue to export anything with index 0 as-is, but add the index for all others - for example:
Thoughts?
The text was updated successfully, but these errors were encountered: