Skip to content
JsonArray

InsertExistingJsonData

void InsertExistingJsonData(JsonData* data)
void InsertExistingJsonData(const std::vector<JsonData*> data)

Will append data to the array.
If called with a vector, it will append every element in the vector.

This will NOT copy 'data'!

'data' will be added directly, and will be freed when the destructor is called!
Use with caution. It IS however more performant than Add()!

Because 'data' will be added directly

You can just call it like this: myArr.InsertExistingJsonData(newJsonData("hello")) without creating a memory leak.

Do NOT call it like this

myArr.InsertExistingJsonData(&myJsonData)
This will cause crashes, because the source myJsonData will get freed, when the scope finishes, but the pointer would still sit in myArr!.

Don't do it!

This function was on the verge of getting "privatized", because it is kinda risky to use and used mostly internally. It is however more performant than Add(), which is why i left it public.