Json: This file requires compiler and library support ....

Created on 14 Oct 2016  路  7Comments  路  Source: nlohmann/json

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

question

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++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.

All 7 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

moneroexamples picture moneroexamples  路  4Comments

mlund picture mlund  路  4Comments

afowles picture afowles  路  3Comments

sqwunkly picture sqwunkly  路  3Comments

Prati369 picture Prati369  路  4Comments