Skip to content

Commit fa09736

Browse files
author
dabinat
committed
Simplified string formatting
1 parent 8ad7e8e commit fa09736

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

native_client/client.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,18 +310,18 @@ JSONOutput(Metadata* metadata)
310310
std::vector<meta_word> words = WordsFromMetadata(metadata);
311311

312312
std::ostringstream out_string;
313-
out_string << "{\"metadata\":{\"confidence\":" << std::to_string(metadata->probability) << "},\"words\":[";
313+
out_string << R"({"metadata":{"confidence":)" << metadata->probability << R"(},"words":[)";
314314

315315
for (int i = 0; i < words.size(); i++) {
316316
meta_word w = words[i];
317-
out_string << "{\"word\":\"" << w.word << "\", \"time\":" << std::to_string(w.start_time) << ", \"duration\":" << std::to_string(w.duration) << "}";
317+
out_string << R"({"word":")" << w.word << R"(","time":)" << w.start_time << R"(,"duration":)" << w.duration << "}";
318318

319319
if (i < words.size() - 1) {
320320
out_string << ",";
321321
}
322322
}
323323

324-
out_string << "]}";
324+
out_string << "]}\n";
325325

326326
return strdup(out_string.str().c_str());
327327
}

0 commit comments

Comments
 (0)