mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-13 22:40:03 -04:00
refactor: folly::dynamic -> nlohmann::json, part 3
This commit is contained in:
parent
0721b199f5
commit
8903957b63
@ -212,14 +212,14 @@ class flac_block_compressor final : public block_compressor::impl {
|
||||
"internal error: flac compression requires metadata");
|
||||
}
|
||||
|
||||
auto meta = folly::parseJson(*metadata);
|
||||
auto meta = nlohmann::json::parse(*metadata);
|
||||
|
||||
auto endianness = meta["endianness"].asString();
|
||||
auto signedness = meta["signedness"].asString();
|
||||
auto padding = meta["padding"].asString();
|
||||
auto num_channels = meta["number_of_channels"].asInt();
|
||||
auto bits_per_sample = meta["bits_per_sample"].asInt();
|
||||
auto bytes_per_sample = meta["bytes_per_sample"].asInt();
|
||||
auto endianness = meta["endianness"].get<std::string>();
|
||||
auto signedness = meta["signedness"].get<std::string>();
|
||||
auto padding = meta["padding"].get<std::string>();
|
||||
auto num_channels = meta["number_of_channels"].get<int>();
|
||||
auto bits_per_sample = meta["bits_per_sample"].get<int>();
|
||||
auto bytes_per_sample = meta["bytes_per_sample"].get<int>();
|
||||
|
||||
assert(1 <= bytes_per_sample && bytes_per_sample <= 4);
|
||||
assert(8 <= bits_per_sample && bits_per_sample <= 32);
|
||||
@ -368,10 +368,10 @@ class flac_block_compressor final : public block_compressor::impl {
|
||||
|
||||
compression_constraints
|
||||
get_compression_constraints(std::string const& metadata) const override {
|
||||
auto meta = folly::parseJson(metadata);
|
||||
auto meta = nlohmann::json::parse(metadata);
|
||||
|
||||
auto num_channels = meta["number_of_channels"].asInt();
|
||||
auto bytes_per_sample = meta["bytes_per_sample"].asInt();
|
||||
auto num_channels = meta["number_of_channels"].get<int>();
|
||||
auto bytes_per_sample = meta["bytes_per_sample"].get<int>();
|
||||
|
||||
compression_constraints cc;
|
||||
|
||||
|
@ -27,10 +27,11 @@
|
||||
|
||||
#include <folly/String.h>
|
||||
#include <folly/container/F14Map.h>
|
||||
#include <folly/json.h>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "dwarfs/checksum.h"
|
||||
#include "dwarfs/entry.h"
|
||||
#include "dwarfs/file_scanner.h"
|
||||
@ -569,7 +570,8 @@ void file_scanner_<LoggerPolicy>::dump_value(std::ostream& os,
|
||||
os << "{\n"
|
||||
<< " \"ptr\": \""
|
||||
<< fmt::format("{}", reinterpret_cast<void const*>(p)) << "\",\n"
|
||||
<< " \"path\": " << folly::toJson(p->path_as_string()) << ",\n"
|
||||
<< " \"path\": " << nlohmann::json{p->path_as_string()}.dump()
|
||||
<< ",\n"
|
||||
<< " \"size\": " << fmt::format("{}", p->size()) << ",\n"
|
||||
<< " \"refcnt\": " << fmt::format("{}", p->refcount()) << ",\n"
|
||||
<< " \"hash\": \"" << folly::hexlify(p->hash()) << "\",\n"
|
||||
|
@ -31,9 +31,10 @@
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
#include <folly/String.h>
|
||||
#include <folly/json.h>
|
||||
#include <folly/lang/Bits.h>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "dwarfs/categorizer.h"
|
||||
#include "dwarfs/mmap.h"
|
||||
|
||||
@ -171,7 +172,7 @@ TEST_F(fits_categorizer, unused_lsb_count_test) {
|
||||
EXPECT_EQ(1, unused_lsb_counts.size());
|
||||
unsigned unused_lsb_count = *unused_lsb_counts.begin();
|
||||
auto json = catmgr->category_metadata(cat);
|
||||
auto metadata = folly::parseJson(json);
|
||||
EXPECT_EQ(unused_lsb_count, metadata["unused_lsb_count"].asInt());
|
||||
auto metadata = nlohmann::json::parse(json);
|
||||
EXPECT_EQ(unused_lsb_count, metadata["unused_lsb_count"].get<int>());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user