From 0d4181b4b663ae491e1bfddaffa40d76ece8b55b Mon Sep 17 00:00:00 2001 From: Ian Holsman Date: Wed, 10 Jun 2020 21:26:20 -0400 Subject: [PATCH] allow null as well as '{}' for empty objects in json --- src/abieos.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/abieos.hpp b/src/abieos.hpp index 5c60ff4..f6289a9 100644 --- a/src/abieos.hpp +++ b/src/abieos.hpp @@ -770,6 +770,16 @@ inline void json_to_bin(std::vector& bin, const abi_type* type, std::strin inline void json_to_bin(pseudo_object*, json_to_bin_state& state, bool allow_extensions, const abi_type* type, bool start) { if (start) { + // accept 'null' as a empty block '{}' + auto t = state.peek_token(); + if (t.get().type == eosio::json_token_type::type_null) { + const std::vector& fields = type->as_struct()->fields; + if (fields.size() ==0) { + state.stack.back(); + state.get_null(); + return; + } + } state.get_start_object(); if (trace_json_to_bin) printf("%*s{ %d fields, allow_ex=%d\n", int(state.stack.size() * 4), "", int(type->as_struct()->fields.size()),