JSON

From Bitpost wiki
Revision as of 15:22, 6 September 2021 by M (talk | contribs) (Created page with "JSON is as simple as possible but no less. Genius. === C++ === We will use boost::json wherever possible. Keep updating it, and move to c++ std json if it becomes a thing....")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

JSON is as simple as possible but no less. Genius.

C++

We will use boost::json wherever possible. Keep updating it, and move to c++ std json if it becomes a thing.

```

   when we need nlohmann:
       using namespace nlohmann::json;
   when we need boost:
       // boost/json.hpp
       using boost::json::value;
       using boost::json::array;
       using boost::json::object;
       using boost::json::value_from;
       using boost::json::parse;
       using boost::json::serialize;
       using boost::json::kind;

```

Library history

  • rapidjson: I started with this. It is brutally low-level and cumbersome (fast? not to develop against...).
  • nlohmann: This was great to code with. Very elegant and straightforward. I moved towards boost to get better performance and a library with "more eyeballs". But this is still used by quicktype, which is used by my Postgres template code, which is really nice... and even tho quicktype is kinda dead... I'm keeping it for as long as I can.
  • boost: I started using boost::json on boost v 1.77, when it seemed to be generally not insane (like its predecessor spirit was...). It's slightly cumbersome, not that bad, and hopefully will get better.