Re:Writing high-performance servers in modern C++
by imaginenore on Monday January 11, 2016 @02:29AM
(#10879365)
No no no, this won't compile. Write the complete code, with all the includes, main function, etc. And write it correctly, iterating over the data, accessing the object fields.
[ Parent
| on HN ]
Re:Writing high-performance servers in modern C++
by matt_d on Monday January 11, 2016 @02:55PM
(#10882895)
All right, then: This one is complete (compiles, runs, iterates through the data, accessing only fields "x" and "y"):
#include <fstream>
#include <json.hpp>
int main()
{
std::ifstream input_file("data.json");
nlohmann::json data;
data << input_file;
for (auto obj : data)
std::cout << obj["x"] << ',' << obj["y"] << '\n';
}
Re:Writing high-performance servers in modern C++
by nmjohn on Monday January 11, 2016 @03:00AM
(#10879490)
There is _absolutley_ no value for a language to provide handy built-in functions that are trivially made available by a library.
If we were talking about language constructs/semantics or flow-control abilities, I'd have a very different opinion - but not having a json decoder builtin, is no reason to use or not use a language.
Re:Writing high-performance servers in modern C++
by imaginenore on Monday January 11, 2016 @05:31AM
(#10879993)
Don't dodge the question. Use any available library you want, just type the code that will compile.