Unable to add new elements in an array: Array as a value of a Map

Hello.

I’m trying to insert new elements in arrays, which are the values of a map.
Keys of the map are string type, and values are float arrays.
In case of array values, I found that UE and C++ don’t support array as a value so I created a simple structure that contains a float array.

Following is a BP for the purpose of initializing a map with values from JSON file.

After building this logic, I confirmed by printing out values every after its addition into an array, and the data were properly printed.
But when I tried to get length of each array afterwards, found out that none of the arrays had value - the printed data above were somehow gone.

I want to initialize a map with data from JSON file.

I am new to the UE and struggled a lot with this issue…
It would be very appreciated with any help and comments. Thank you!

The find function in a map does not return a reference, but rather a copy. Therefore, after you perform operations on this copy, you need to re-add it to the map, similar to this:

3 Likes

Thank you for your help!

So the find method literally just finds value from a map and if I want to update the value, I need to re-set the map…
I modified the BP and it’s working very well.

Thank you again! :grinning:

It’s my honor to be able to help you. Please mark this post as solved.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.