Hi,
I trying to use your library but when I trying to compile example I getting error:
error This file requires compiler and library support for the \
ISO C++ 2011 standard. This support is currently experimental, and must be \
enabled with the -std=c++11 or -std=gnu++11 compiler options.
I'm using Dev C++ 5.11. I setted language standard into ISO C++ 11 but I getting still the same error.
What is bad?
Windows 10 Home x64
Dev C++ 5.11
TDM-GCC 4.9.2 64-bit Release
As you can see, GCC is on 6.2 now https://gcc.gnu.org/
You have to update your compiler to a newer version.
GCC 4.9.2 should be capable to compile the library (in fact, there is a preprocessor check that yields an error if the compiler is too old). But as the error message says: you need to pass -std=c++11 to the compiler flags. I have not used Dev C++, so I do not know how to set the flags. Maybe search for CXXFLAGS.
Ok, I fix it.
I have one more question - how to convert JSON from file into array?
I'm loading file by:
json ss;
std::ifstream ifs("data/test.json");
ifs >> ss;
and here is this JSON file:
{
"cols": [
"id",
"title",
"quantity",
"price"
],
"data": [
[
1,
"Guzman",
16,
"6.31"
],
[
2,
"Berry",
3,
"4.34"
],
[
3,
"Golden",
8,
"4.15"
]
]
}
I do not understand the question. To what type do you want to convert your JSON?
I have JSON:
{ "cols": [ "id", "title", "quantity", "price" ], "data": [ [ 1, "Guzman", 16, "6.31" ], [ 2, "Berry", 3, "4.34" ], [ 3, "Golden", 8, "4.15" ] ] }
and now I want to create array with this data.
Say your JSON object is stored in variable ss. Then you could access with ss["data"] the array
[
[
1,
"Guzman",
16,
"6.31"
],
[
2,
"Berry",
3,
"4.34"
],
[
3,
"Golden",
8,
"4.15"
]
]
Thanks for help
Most helpful comment
GCC 4.9.2 should be capable to compile the library (in fact, there is a preprocessor check that yields an error if the compiler is too old). But as the error message says: you need to pass
-std=c++11to the compiler flags. I have not used Dev C++, so I do not know how to set the flags. Maybe search forCXXFLAGS.