添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parseFromStream() copies the document couple of times. To me it does not look like a usable level on high-performance server.

Why parseFromChar and parseFromString are not provided? mapping them to stringstream to use parseFromStrea() costs a lot.

Why CharReader is unable to be created on stack? I cannot understand the benefit to use 'new' for this on-shot object.

parseFromStream() copies the document couple of times. To me it does not look like a usable level on high-performance server.

True.

Why parseFromChar and parseFromString are not provided?

Because they are trivial.

Json::Value root;
reader->parse(beg, end, &root);

Why CharReader is unable to be created on stack?

An object on the stack cannot have its size changed. Backward-compatibility constrains enhancements, and sometimes even bug-fixes. In the past, that constraint made this library difficult to maintain.

Readers are not thread-safe, but they generally are re-usable. So I don't see the reason for objections.

  • http://open-source-parsers.github.io/jsoncpp-docs/doxygen/index.html
  • Json::CharReaderBuilder rbuilder;
    std::unique_ptr<Json::CharReader> const reader(rbuilder.newCharReader());
    std::string const mystring = whatever;
    char const* start = mystring.c_str();
    char const* stop = start + mystring.size();
    Json::Value value1;
    std::string errs;
    reader->parse(start, stop, &value1, &errs);

    start and stop delimit the string.