mirror of
https://github.com/CrowCpp/Crow.git
synced 2024-06-07 21:10:44 +00:00
f39b9ddce7
Added pop() method to query_string, same as get(), but removes the item from the querystring Added std::string() operator to json::rvalue (allows std::string(json["abc"]), which returns any value that isn't a container to string) Added lo() method to json::rvalue, returns a vector of json::rvalue containing whatever a json object or list has (difference being a list has no keys) Added keys() method to json::rvalue, returns a vector of std::string containing the keys of a json object Made json::wvalue use either std::map or std::unordered_map instead of just std::unordered_map Added copy constructor to json::wvalue Added size() method to json::wvalue, returns 1 or the size of the json list. Added constructor to create json::wvalue from std::vector Added keys() method to query_string Documented query_string and improved json doc Made tests and examples for all the additions
29 lines
516 B
C++
29 lines
516 B
C++
#define CROW_MAIN
|
|
#define CROW_JSON_USE_MAP
|
|
#include "crow.h"
|
|
|
|
|
|
|
|
int main()
|
|
{
|
|
crow::SimpleApp app;
|
|
|
|
// simple json response using a map
|
|
// To see it in action enter {ip}:18080/json
|
|
// it shoud show amessage before zmessage despite adding zmessage first.
|
|
CROW_ROUTE(app, "/json")
|
|
([]{
|
|
crow::json::wvalue x;
|
|
x["zmessage"] = "Hello, World!";
|
|
x["amessage"] = "Hello, World2!";
|
|
return x;
|
|
});
|
|
|
|
// enables all log
|
|
app.loglevel(crow::LogLevel::Debug);
|
|
|
|
app.port(18080)
|
|
.multithreaded()
|
|
.run();
|
|
}
|