雾聪
2023-10-23 b8d7c62b8c0a5955799524231ca927634abfbbd2
optimize json parse
2个文件已修改
19 ■■■■ 已修改文件
funasr/runtime/websocket/bin/websocket-server-2pass.cpp 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
funasr/runtime/websocket/bin/websocket-server.cpp 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
funasr/runtime/websocket/bin/websocket-server-2pass.cpp
@@ -356,7 +356,14 @@
  unique_lock guard_decoder(*(thread_lock_p)); // mutex for one connection
  switch (msg->get_opcode()) {
    case websocketpp::frame::opcode::text: {
      nlohmann::json jsonresult = nlohmann::json::parse(payload);
      nlohmann::json jsonresult;
      try{
        jsonresult = nlohmann::json::parse(payload);
      }catch (std::exception const &e)
      {
        LOG(ERROR)<<e.what();
        break;
      }
      if (jsonresult.contains("wav_name")) {
        msg_data->msg["wav_name"] = jsonresult["wav_name"];
funasr/runtime/websocket/bin/websocket-server.cpp
@@ -256,7 +256,15 @@
  unique_lock guard_decoder(*(thread_lock_p)); // mutex for one connection
  switch (msg->get_opcode()) {
    case websocketpp::frame::opcode::text: {
      nlohmann::json jsonresult = nlohmann::json::parse(payload);
      nlohmann::json jsonresult;
      try{
        jsonresult = nlohmann::json::parse(payload);
      }catch (std::exception const &e)
      {
        LOG(ERROR)<<e.what();
        break;
      }
      if (jsonresult["wav_name"] != nullptr) {
        msg_data->msg["wav_name"] = jsonresult["wav_name"];
      }