mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-01-01 11:29:17 +00:00
Some JSON C++ library example code "levelling"
Signed-off-by: Adrian Conlon <adrian.conlon@gmail.com>
This commit is contained in:
parent
500e65b895
commit
50cea1b81a
@ -31,8 +31,8 @@ void state_t::initialise(const boost::json::object& serialised) {
|
||||
for (const auto& ram_entry : ram_entries) {
|
||||
const auto& ram_entry_array = ram_entry.as_array();
|
||||
assert(ram_entry_array.size() == 2);
|
||||
const auto address = (uint16_t)ram_entry_array[0].as_int64();
|
||||
const auto value = (uint8_t)ram_entry_array[1].as_int64();
|
||||
const auto address = (uint16_t)ram_entry_array.at(0).as_int64();
|
||||
const auto value = (uint8_t)ram_entry_array.at(0).as_int64();
|
||||
m_ram[address] = value;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
//#define TEST_JSON_PERFORMANCE
|
||||
|
||||
#define USE_SIMDJSON_JSON // 16 seconds
|
||||
//#define USE_BOOST_JSON // 31 seconds
|
||||
//#define USE_BOOST_JSON // 28 seconds
|
||||
//#define USE_NLOHMANN_JSON // 73 seconds
|
||||
//#define USE_JSONCPP_JSON // 105 seconds
|
||||
|
||||
|
@ -41,9 +41,9 @@ void test_t::initialise(const boost::json::object& serialised) {
|
||||
for (const auto& cycles_entry : cycles_array) {
|
||||
const auto& cycle_array = cycles_entry.as_array();
|
||||
assert(cycle_array.size() == 3);
|
||||
const auto address = (uint16_t)cycle_array[0].as_int64();
|
||||
const auto contents = (uint8_t)cycle_array[1].as_int64();
|
||||
const auto action = to_action((std::string)cycle_array[2].as_string());
|
||||
const auto address = (uint16_t)cycle_array.at(0).as_int64();
|
||||
const auto contents = (uint8_t)cycle_array.at(1).as_int64();
|
||||
const auto action = to_action((std::string)cycle_array.at(2).as_string());
|
||||
m_cycles.push_back({ address, contents, action });
|
||||
}
|
||||
}
|
||||
|
@ -24,19 +24,17 @@ int main() {
|
||||
opcode.parse();
|
||||
|
||||
#ifdef USE_BOOST_JSON
|
||||
assert(opcode.raw().is_array());
|
||||
const auto& opcode_test_array = opcode.raw().as_array();
|
||||
#endif
|
||||
#ifdef USE_NLOHMANN_JSON
|
||||
assert(opcode.raw().is_array());
|
||||
const auto& opcode_test_array = opcode.raw();
|
||||
assert(opcode_test_array).is_array());
|
||||
#endif
|
||||
#ifdef USE_JSONCPP_JSON
|
||||
assert(opcode.raw().is_array());
|
||||
const auto& opcode_test_array = opcode.raw();
|
||||
assert(opcode_test_array.is_array());
|
||||
#endif
|
||||
#ifdef USE_SIMDJSON_JSON
|
||||
assert(opcode.raw().is_array());
|
||||
const auto opcode_test_array = opcode.raw().get_array();
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user