mirror of
https://github.com/nlohmann/json.git
synced 2026-09-25 01:10:30 +00:00
Merge remote-tracking branch 'origin/develop' into pr5389-merge
# Conflicts: # .github/workflows/ubuntu.yml # cmake/ci.cmake
This commit is contained in:
@@ -20384,6 +20384,16 @@ class binary_writer
|
||||
};
|
||||
|
||||
string_t key = "_ArrayType_";
|
||||
// the type name is looked up as a string below; a non-string
|
||||
// annotation (e.g. a number, null, or an array) cannot name a known
|
||||
// dtype, so it is treated the same as an unrecognized type name and
|
||||
// falls back to a plain object encoding instead of throwing
|
||||
// type_error.302 out of get<string_t>()
|
||||
if (!value.at(key).is_string())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// use get<string_t>() instead of static_cast<string_t> to avoid an
|
||||
// ambiguous conversion under explicit instantiation on C++17 (see #4825)
|
||||
auto it = bjdtype.find(value.at(key).template get<string_t>());
|
||||
@@ -20393,6 +20403,16 @@ class binary_writer
|
||||
}
|
||||
CharType dtype = it->second;
|
||||
|
||||
// the 'B' (byte) marker is only defined from BJData Draft 3 onward;
|
||||
// emitting it under an earlier draft would produce a stream that an
|
||||
// earlier-draft reader rejects, so such an object falls back to a
|
||||
// plain object encoding instead (see the "Binary values" section of
|
||||
// the BJData documentation)
|
||||
if (dtype == 'B' && bjdata_version < bjdata_version_t::draft3)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
key = "_ArraySize_";
|
||||
// the dimensions are written verbatim as the header length below, so a
|
||||
// value that is not an array cannot produce a valid one: null emits 'Z'
|
||||
|
||||
Reference in New Issue
Block a user