benchmarks
benchmarks copied to clipboard
Update test_boost_json.cpp
This shows the Boost JSON in a better light and uses safer at( ) instead of operator[] that will insert if the member doesn't exist. At throws. It also uses a more idiomatic, for read only JSON, use of memory_resource similar to RapidJSON's pooled allocator.
If you want safer operations, I'd recommend to change get_
to as_
too (i.e. use as_double
instead of get_double
). I deliberately used unsafe []-operator because we know ahead that the original JSON have the proper format, however in the real life I guess we want to use the safer operations as usually JSON values come across the trust boundaries.
At is also faster than operator[] when I was checking. It has a const overload too, so if the object is const it would still work.