Boost logo

Boost :

From: Hadriel Kaplan (hadrielk_at_[hidden])
Date: 2020-09-24 15:07:11

> On Sep 24, 2020, at 7:06 AM, Mike via Boost <boost_at_[hidden]> wrote:
> Whether c++ is in need of a JSON vocabulary type and if Boost.JSON
> does provide a good one is a question I unfortunately can't answer yet
> (otherwise I'd have written a review), but imho the worth of that library
> should not just be measured by whether it is suited as a general
> vocabulary type for the whole c++ eco system, but if it provides a
> sound (doesn't necessarily need to be optimal) basis for building
> higher level libs on top of it in the future (inside and outside of boost).
> (e.g. implementing JSON based internet protocols).

This is anecdotal, of course, but within my company’s codebase the equivalent JSON-based variant structure is indeed used as a vocabulary type and passed between libraries - although of course they’re our own libraries, so it’s not really what you mean. It’s extremely convenient and its usage has become somewhat viral.

We use Facebook’s `folly::dynamic` for that variant type today, and out of an average size (1M+ LOC) code base, the string “folly::dynamic” appears over 7,600 times. A lot of that usage is in unit test code+libraries, where we use the type for various purposes, but a lot of it is also in production code. It is *not* only used for when we need parsing or serialization to/from JSON, although certainly that’s a big usage too; and makes it even more convenient as a value type because we can serialize it to logs for debugging, or parse from strings/files for unit testing library APIs.

Of course the downside with using such a dynamically-typed structure as a vocab type is it it won’t be as efficient as statically-typed ones, and if you put the wrong stuff in it you won’t get compile-time failures. But that’s an acceptable trade-off for some people/use-cases.


Boost list run by bdawes at, gregod at, cpdaniel at, john at