Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

Commit

Permalink
(maint) Merge up 3c44bae to master
Browse files Browse the repository at this point in the history
Generated by CI

* commit '3c44baee4cdd4025edf6a268568ccb072cda26d7':
  (LTH-169) Pretty print integers as int64_t
  • Loading branch information
puppetlabs-jenkins committed Oct 25, 2019
2 parents 5ac4b00 + 3c44bae commit 8e8a8a8
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion json_container/src/json_container.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ namespace leatherman { namespace json_container {
formatted_data += get<std::string>(key);
break;
case DataType::Int:
formatted_data += std::to_string(get<int>(key));
formatted_data += std::to_string(get<int64_t>(key));
break;
case DataType::Bool:
if (get<bool>(key)) {
Expand Down Expand Up @@ -376,6 +376,19 @@ namespace leatherman { namespace json_container {
return value.GetInt();
}

template<>
int64_t JsonContainer::getValue<>(const json_value& value) const {
if (value.IsNull()) {
return 0;
}

if (!value.IsInt64()) {
throw data_type_error { _("not an integer") };
}

return value.GetInt64();
}

template<>
bool JsonContainer::getValue<>(const json_value& value) const {
if (value.IsNull()) {
Expand Down

0 comments on commit 8e8a8a8

Please sign in to comment.