From: Maxim Mamontov Date: Mon, 31 Aug 2015 18:53:03 +0000 (+0300) Subject: Minor fixes in JSON parser. X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/9000c743ff21403975bc65780b4291a9ef68990e Minor fixes in JSON parser. --- diff --git a/stglibs/json.lib/include/stg/json_parser.h b/stglibs/json.lib/include/stg/json_parser.h index 73009d2f..d20e669d 100644 --- a/stglibs/json.lib/include/stg/json_parser.h +++ b/stglibs/json.lib/include/stg/json_parser.h @@ -55,7 +55,7 @@ class Parser virtual ~Parser(); bool append(const char* data, size_t size); - bool done(); + bool last(); private: class Impl; diff --git a/stglibs/json.lib/parser.cpp b/stglibs/json.lib/parser.cpp index 5547b697..57115048 100644 --- a/stglibs/json.lib/parser.cpp +++ b/stglibs/json.lib/parser.cpp @@ -34,8 +34,8 @@ class Parser::Impl yajl_free(m_handle); } - bool append(const char* data, size_t size) { return yajl_parse(m_handle, reinterpret_cast(data), size) != yajl_status_ok; } - bool done() { return yajl_complete_parse(m_handle) != yajl_status_ok; } + bool append(const char* data, size_t size) { return yajl_parse(m_handle, reinterpret_cast(data), size) == yajl_status_ok; } + bool last() { return yajl_complete_parse(m_handle) == yajl_status_ok; } static int parseNull(void* ctx) { return runParser(ctx, &NodeParser::parseNull); } @@ -100,6 +100,7 @@ Parser::Impl::Impl(NodeParser* topParser) : m_handle(yajl_alloc(&callbacks, NULL, this)), m_parser(topParser) { + yajl_config(m_handle, yajl_allow_multiple_values, 1); } Parser::Parser(NodeParser* topParser) @@ -116,7 +117,7 @@ bool Parser::append(const char* data, size_t size) return m_impl->append(data, size); } -bool Parser::done() +bool Parser::last() { - return m_impl->done(); + return m_impl->last(); }