Browse Source

Fixing bug where booleans did not advance the tracker.

Samuel Jaffe 8 years ago
parent
commit
bcbc63184b

+ 2 - 0
json/json_binder_discard.cpp

@@ -35,8 +35,10 @@ namespace json { namespace {
       helper::parse_string(json, ++data);
     } else if (!strncmp(data, "true", 4)) {
       json = true;
+      data += 4;
     } else if (!strncmp(data, "false", 5)) {
       json = false;
+      data += 5;
     } else {
       helper::parse_numeric(json, data);
     }

+ 2 - 1
json/json_direct_binder.hpp

@@ -38,7 +38,8 @@ namespace json { namespace binder {
       T value;
     };
   public:
-    value_binder() : impl(&detail::value) {}
+    template <typename... Args>
+    value_binder(Args &&... args) : impl(&detail::value, args...) {}
     
     virtual binder_impl<T>* clone() const override {
       return new value_binder(*this);

+ 2 - 0
json/json_direct_scalar_binder.hpp

@@ -17,8 +17,10 @@ namespace json { namespace binder {
     virtual void parse(T& val, char const*& data, parser::options) const override {
       if (!strncmp(data, "true", 4)) {
         val.*ptr = true;
+        data += 4;
       } else if (!strncmp(data, "false", 5)) {
         val.*ptr = false;
+        data += 5;
       } else {
         throw json::malformed_json_exception("Expected a boolean type here");
       }

+ 1 - 1
json/json_tuple_binder.hpp

@@ -23,7 +23,7 @@ namespace json { namespace binder {
       if (ch == '[') {
         parse_tuple(object, ++data, opts);
       } else {
-        throw json::malformed_json_exception(std::string("Expected an object type for binding to ") + typeid(T).name());
+        throw json::malformed_json_exception(std::string("Expected an array type for binding to ") + typeid(T).name());
       }
     }