Skip to content

Commit

Permalink
Correctly generate "space" key in the JSON REST server output.
Browse files Browse the repository at this point in the history
Before, the last token would get "spaces" instead of "space".

Fixes #20.
  • Loading branch information
foxik committed May 18, 2023
1 parent ddb9536 commit a2232fd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/rest_server/morphodita_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ bool morphodita_service::handle_rest_tag(microrestd::rest_request& req) {
bool next(bool first) {
if (!tokenizer->next_sentence(&forms, nullptr)) {
if (output.mode == XML && *unprinted) json.value_xml_escape(unprinted, true);
if (output.mode == JSON && !first && *unprinted) json.key("spaces").value(unprinted);
if (output.mode == JSON && !first && *unprinted) json.key("space").value(unprinted);
if (output.mode == JSON && !first) json.close().close();
return false;
}
Expand Down Expand Up @@ -247,7 +247,7 @@ bool morphodita_service::handle_rest_analyze(microrestd::rest_request& req) {
bool next(bool first) {
if (!tokenizer->next_sentence(&forms, nullptr)) {
if (output.mode == XML && *unprinted) json.value_xml_escape(unprinted, true);
if (output.mode == JSON && !first && *unprinted) json.key("spaces").value(unprinted);
if (output.mode == JSON && !first && *unprinted) json.key("space").value(unprinted);
if (output.mode == JSON && !first) json.close().close();
return false;
}
Expand Down Expand Up @@ -388,7 +388,7 @@ bool morphodita_service::handle_rest_tokenize(microrestd::rest_request& req) {
bool next(bool first) {
if (!tokenizer->next_sentence(&forms, nullptr)) {
if (output.mode == XML && *unprinted) json.value_xml_escape(unprinted, true);
if (output.mode == JSON && !first && *unprinted) json.key("spaces").value(unprinted);
if (output.mode == JSON && !first && *unprinted) json.key("space").value(unprinted);
if (output.mode == JSON && !first) json.close().close();
return false;
}
Expand Down

0 comments on commit a2232fd

Please sign in to comment.