Writing a new line in a Json file

I’m writing data into a json file with “of 0.10.0”
For example it’s {"data1 ":“mydata1”, “data2”:“mydata2”, "data3:“mydata3”}
Every time I had new data to my json file it add it on the same line
{"data1 ":“mydata1”, “data2”:“mydata2”, "data3:“mydata3”}, {"data1 “:“mydata1b”, “data2”:“mydata2b”, “data3:“mydata3b”}
I’m trying to make a new line each time I had new data to make it more human friendly.
I’ve tried this solution
myJsonFile.push_back(”\\n”) but it’s adding the data “\\n” instead of creating a new line
Does anyone know a way to add command to the json file instead of data ?

ofJson is an alias of https://github.com/nlohmann/json. I’d highly recommend reviewing the syntax there. It’s very well documented. It looks like you are trying to make a json array, so the push_back approach is correct, but will need to be something more like:

ofJson a;
a["data1"] = "mydata1";

ofJson b;
b["data1"] = "mydata1b";

ofJson data;
data.push_back(a);
data.push_back(b);

std::cout << data.dump(4) << std::endl;

This will yield

[
    {
        "data1": "mydata1"
    },
    {
        "data1": "mydata1b"
    }
]