8000 remove extra JSON parser (#10282) · arangodb/arangodb@c3d8ef8 · GitHub
[go: up one dir, main page]

Skip to content

Commit c3d8ef8

Browse files
authored
remove extra JSON parser (#10282)
1 parent 525b8f7 commit c3d8ef8

File tree

6 files changed

+30
-3541
lines changed

6 files changed

+30
-3541
lines changed

arangosh/Shell/V8ClientConnection.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include <fuerte/jwt.h>
2929
#include <fuerte/requests.h>
3030
#include <v8.h>
31-
#include <iostream>
3231

3332
#include "Basics/FileUtils.h"
3433
#include "Basics/StringUtils.h"
@@ -44,10 +43,14 @@
4443
#include "SimpleHttpClient/SimpleHttpResult.h"
4544
#include "Ssl/SslInterface.h"
4645
#include "V8/v8-conv.h"
47-
#include "V8/v8-json.h"
4846
#include "V8/v8-utils.h"
4947
#include "V8/v8-vpack.h"
5048

49+
#include <velocypack/Builder.h>
50+
#include <velocypack/Parser.h>
51+
#include <velocypack/Slice.h>
52+
#include <velocypack/velocypack-aliases.h>
53+
5154
#include <iostream>
5255

5356
using namespace arangodb;
@@ -1747,12 +1750,15 @@ v8::Local<v8::Value> V8ClientConnection::handleResult(v8::Isolate* isolate,
17471750
char const* str = reinterpret_cast<char const*>(sb.data());
17481751

17491752
if (res->isContentTypeJSON()) {
1750-
char* error = nullptr;
1751-
v8::Local<v8::Value> ret = TRI_FromJsonString(isolate, str, sb.size(), &error);
1752-
if (error != nullptr) {
1753+
v8::Local<v8::Value> ret;
1754+
auto builder = std::make_shared<VPackBuilder>();
1755+
VPackParser parser(builder);
1756+
try {
1757+
parser.parse(str, sb.size());
1758+
ret = TRI_VPackToV8(isolate, builder->slice(), parser.options, nullptr);
1759+
} catch (std::exception const& ex) {
17531760
std::string err("Error parsing the server JSON reply: ");
1754-
err += error;
1755-
free(error);
1761+
err += ex.what();
17561762
TRI_CreateErrorObject(isolate, TRI_ERROR_HTTP_CORRUPTED_JSON, err, true);
17571763
}
17581764
return ret;

lib/CMakeLists.txt

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,6 @@
22

33
include_directories(.)
44

5-
################################################################################
6-
## BISON/FLEX
7-
################################################################################
8-
9-
# note that we check-in the generated FLEX/BISON files, therefore they are
10-
# generate inside the source tree
11-
12-
if (USE_MAINTAINER_MODE AND NOT MSVC)
13-
add_custom_command(
14-
OUTPUT ${CMAKE_SOURCE_DIR}/lib/V8/v8-json.cpp
15-
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
16-
COMMAND ${FLEX_EXECUTABLE} -L -olib/V8/v8-json.cpp lib/V8/v8-json.ll
17-
MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/lib/V8/v8-json.ll
18-
VERBATIM
19-
)
20-
21-
add_custom_target(clean_lib_autogenerated
22-
COMMAND rm -f ${CMAKE_SOURCE_DIR}/lib/V8/v8-json.cpp)
23-
24-
list(APPEND CLEAN_AUTOGENERATED_FILES clean_lib_autogenerated)
25-
set(CLEAN_AUTOGENERATED_FILES ${CLEAN_AUTOGENERATED_FILES} PARENT_SCOPE)
26-
endif ()
27-
28-
29-
if (CMAKE_COMPILER_IS_GNUCC)
30-
set_source_files_properties(V8/v8-json.cpp PROPERTIES COMPILE_FLAGS -Wno-sign-compare)
31-
endif ()
32-
335
################################################################################
346
## LIB_ARANGO
357
################################################################################
@@ -309,7 +281,6 @@ add_library(arango_v8 STATIC
309281
V8/v8-buffer.cpp
310282
V8/v8-conv.cpp
311283
V8/v8-globals.cpp
312-
V8/v8-json.cpp
313284
V8/v8-shell.cpp
314285
V8/v8-utils.cpp
315286
V8/v8-vpack.cpp

0 commit comments

Comments
 (0)
0