Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

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

allow null as well as '{}' for empty objects in json #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/abieos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,16 @@ inline void json_to_bin(std::vector<char>& 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<eosio::abi_field>& 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()),
Expand Down