Skip to content
JasonPP::

JsonArray

class JsonArray
JsonArray()
JsonArray(const std::vector<JsonData> elements)
JsonArray(const JsonArray& otherArr)

A class that represents arrays in json.
Basically just a wrapper for std::vector<JsonData*>, which takes care of stuff like memory management, deep copying and a bunch of other quality-of-life improvements.

If you do not wish to use JsonArray, JsonData objects still accept normal std::vector<JsonData>'s, and even std::vector<bool/int/float/std::string/etc...>'s.


Inline creation

Arr{ 1, 2, 3, 4, "I'm an array!"}
Arr{ int1, int2, float1, bool1, string1 }

Arr{ JsonData(Arr{"You can even put", "arrays into arrays"}) }

Constructors:

empty/no constructor: Will create an empty array.

const std::vector<JsonData> elements: Will initialize this array with copies of these existing JsonData objects.

const JsonArray& otherArr: Will create itself as a deep-copy of otherArr.