Skip to content

Commit 85b908c

Browse files
committed
fix: fix result of CustomForm
1 parent 72b7e82 commit 85b908c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/lse/api/helper/CustomFormWrapper.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "CustomFormWrapper.h"
22

33
#include "nlohmann/json.hpp"
4+
#include "nlohmann/json_fwd.hpp"
45

56
namespace lse::form {
67

@@ -10,8 +11,8 @@ CustomFormWrapper::convertResult(std::optional<std::string> const& result, std::
1011
auto data = nlohmann::ordered_json::parse(*result);
1112
if (!data.is_null() && !data.is_array()) return {};
1213

13-
auto iter = resultIndices.rbegin();
14-
size_t count = iter == resultIndices.rend() ? 0 : *iter;
14+
size_t count = resultIndices.size();
15+
if (data.size() == 0) return nlohmann::ordered_json::array({});
1516
if (data.size() == count) {
1617
return data;
1718
}
@@ -28,7 +29,7 @@ CustomFormWrapper::convertResult(std::optional<std::string> const& result, nlohm
2829
if (!result) return {};
2930
auto type = formData.find("type");
3031
auto content = formData.find("content");
31-
if (content == formData.end() || type == formData.end() || *type != "custom") {
32+
if (content == formData.end() || type == formData.end() || *type != "custom_form") {
3233
return nlohmann::ordered_json::parse(*result);
3334
}
3435
std::vector<int> resultIndices{};

0 commit comments

Comments
 (0)