How to Add/Append Value to FJsonValueArray in C++?

Hello,

I’m looking to build a JSON object that contains an array that I can serialize and write as a file / load it back into memory.

What is baffling me is there doesn’t seem to be a way to actually add values to a FJsonValueArray in C++ which seems quite strange.

(I’ve tried .Add, ->Add , ->Append, but all failing to compile.)

There doesn’t seem to be any way in the documentation to do this… (I’m using UE5.1)

Any help would be appreciated.

Thanks!

Bump!

I’d think dealing with JSON would be quite trivial. Anyone?

I was able to figure it out. I will post my solution for others in case they run into this issue in the future.

I changed the type from TSharedPtr<FJsonValueArray> to TArray<TSharedPtr<FJsonValue>>

After that, the .Add function was recognized and worked.

Best of luck to you all!

1 Like