How to make JSON Pretty?
GuckTubeYT opened this issue · 2 comments
GuckTubeYT commented
I want to make JSON Like this
{
"array":[
{
"key":"value"
}
]
}
But, why its like this = {"array":[{"key":"value"}]}
json::jobject obj2;
obj2["key"] = "value";
std::vector<json::jobject> vec;
vec.push_back(obj2);
json::jobject example;
example["array"] = vec;
cout << (string) example << endl;
gregjesl commented
Hey @GuckTubeYT, right now serialization makes the string as small as possible but I'm working on a method that creates a "pretty" string.
gregjesl commented
@GuckTubeYT My latest commit adds a .pretty()
method that will generate the type of output you're looking for:
json::jobject obj2;
obj2["key"] = "value";
std::vector<json::jobject> vec;
vec.push_back(obj2);
json::jobject example;
example["array"] = vec;
cout << example.pretty() << endl;