Skip to content

Create a basic array


Example on how to create a basic array like this:

Will create json:
[
    "Ethel Cline",
    "Rayhaan Newton",
    "Neil Dominguez",
    "Elicia Goff",
    "Martyn Nunez"
]
Procedural (C++):
Json json = JsonData(JSON_DATA_TYPE::ARRAY); // Create empty JsonData of type ARRAY

json.AsArray.Add(std::string("Ethel Cline"));
json.AsArray.Add(std::string("Rayhaan Newton"));
json.AsArray.Add(std::string("Neil Dominguez"));
json.AsArray.Add(std::string("Elicia Goff"));
json.AsArray.Add(std::string("Martyn Nunez"));

std::cout << json.Render() << std::endl;
Inline (C++):
Json json = JsonData(JsonArray({
    std::string("Ethel Cline"),
    std::string("Rayhaan Newton"),
    std::string("Neil Dominguez"),
    std::string("Elicia Goff"),
    std::string("Martyn Nunez")
}));

std::cout << json.Render() << std::endl;