Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return crow::json::wvalue doesn't work for non "json object" types. #69

Closed
The-EDev opened this issue Nov 25, 2020 · 1 comment · Fixed by #70
Closed

return crow::json::wvalue doesn't work for non "json object" types. #69

The-EDev opened this issue Nov 25, 2020 · 1 comment · Fixed by #70
Labels
bug Something isn't working
Milestone

Comments

@The-EDev
Copy link
Member

The-EDev commented Nov 25, 2020

in the handler lambda, if you do return value_item withvalue_time being a list crow::json::wvalue object, you get nothing, it only works if you do return crow::response(value_item).

This is also true for all other non object types.

This is the code I used

CROW_ROUTE(app, "/json/thing")
([](){
        crow::json::wvalue value_item;
        std::vector<int> value_list;
        value_list.emplace_back(5);
        value_list.emplace_back(2);
        value_list.emplace_back(3);
        value_list.emplace_back(4);
        value_item = value_list;
        return value_item;
});
@The-EDev The-EDev added the bug Something isn't working label Nov 25, 2020
@The-EDev The-EDev added this to the v0.3 milestone Nov 25, 2020
@The-EDev The-EDev changed the title return crow::json::wvalue doesn't work for json lists. return crow::json::wvalue doesn't work for non "json object" types. Nov 25, 2020
@The-EDev
Copy link
Member Author

Found the culprit, line 415 in http_connection.h says if (res.body.empty() && res.json_value.t() == json::type::Object), should probably be changed to != json::type::Null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant