mirror of https://gitee.com/bigwinds/arangodb
remove TRI_json_t
This commit is contained in:
parent
1d124b8166
commit
51bfb8fe57
|
@ -133,6 +133,14 @@ class Parser {
|
||||||
return parser.steal();
|
return parser.steal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::shared_ptr<Builder> fromJson(
|
||||||
|
char const* start, size_t size,
|
||||||
|
Options const* options = &Options::Defaults) {
|
||||||
|
Parser parser(options);
|
||||||
|
parser.parse(start, size);
|
||||||
|
return parser.steal();
|
||||||
|
}
|
||||||
|
|
||||||
static std::shared_ptr<Builder> fromJson(
|
static std::shared_ptr<Builder> fromJson(
|
||||||
uint8_t const* start, size_t size,
|
uint8_t const* start, size_t size,
|
||||||
Options const* options = &Options::Defaults) {
|
Options const* options = &Options::Defaults) {
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
#include <unicode/smpdtfmt.h>
|
#include <unicode/smpdtfmt.h>
|
||||||
#include <unicode/dtfmtsym.h>
|
#include <unicode/dtfmtsym.h>
|
||||||
|
|
||||||
|
#include <velocypack/Iterator.h>
|
||||||
#include <velocypack/Slice.h>
|
#include <velocypack/Slice.h>
|
||||||
#include <velocypack/velocypack-aliases.h>
|
#include <velocypack/velocypack-aliases.h>
|
||||||
|
|
||||||
|
@ -2833,23 +2834,20 @@ static void ListDatabasesCoordinator(
|
||||||
// We got an array back as JSON, let's parse it and build a v8
|
// We got an array back as JSON, let's parse it and build a v8
|
||||||
StringBuffer& body = res->result->getBody();
|
StringBuffer& body = res->result->getBody();
|
||||||
|
|
||||||
TRI_json_t* json = JsonHelper::fromString(body.c_str());
|
std::shared_ptr<VPackBuilder> builder = VPackParser::fromJson(body.c_str(), body.length());
|
||||||
|
VPackSlice resultSlice = builder->slice();
|
||||||
|
|
||||||
if (json != 0 && JsonHelper::isObject(json)) {
|
if (resultSlice.isObject()) {
|
||||||
TRI_json_t const* dotresult =
|
VPackSlice r = resultSlice.get("result");
|
||||||
JsonHelper::getObjectElement(json, "result");
|
if (r.isArray()) {
|
||||||
|
uint32_t i = 0;
|
||||||
if (dotresult != 0) {
|
|
||||||
std::vector<std::string> list =
|
|
||||||
JsonHelper::stringArray(dotresult);
|
|
||||||
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json);
|
|
||||||
v8::Handle<v8::Array> result = v8::Array::New(isolate);
|
v8::Handle<v8::Array> result = v8::Array::New(isolate);
|
||||||
for (size_t i = 0; i < list.size(); ++i) {
|
for (auto const& it : VPackArrayIterator(r)) {
|
||||||
result->Set((uint32_t)i, TRI_V8_STD_STRING(list[i]));
|
std::string v = it.copyString();
|
||||||
|
result->Set(i++, TRI_V8_STD_STRING(v));
|
||||||
}
|
}
|
||||||
TRI_V8_RETURN(result);
|
TRI_V8_RETURN(result);
|
||||||
}
|
}
|
||||||
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue