I am attempting to use the Json function SetArrayField
, which takes const TArray>
as its second argument. I have an array of FJsonValueString which I wish to pass to this argument.
Standard C++ const_cast tells me that it cannot convert from ‘TArray,FDefaultAllocator>’ to ‘TArray,FDefaultAllocator>’
I’ve seen that TSharedPtr has ConstCastSharedPtr( … ). Should I use this? How would I do that?
I solved this issue by doing a couple things.
The first is that SetArrayField wants const TArray(TSharedPtr(FJsonValue))
, so using FJsonValueString was not going to work, ever.
I assigned my FJsonValues by doing this:
TSharedPtr<FJsonValue> Value = MakeShareable(new FJsonValueString(JsonString));
JsonActionArray.Add(Value);
When it came time to call the SetArrayField function, I did:
SetArrayField(Field, (const TArray< TSharedPtr< FJsonValue > >) JsonActionArray);