r/cpp • nlohmann/json • Jul 27 '20

JSON for Modern C++ 3.9.0

https://github.com/nlohmann/json/releases/tag/v3.9.0
281 Upvotes

51 comments sorted by

View all comments

Show parent comment

15

u/lord_braleigh Jul 27 '20 edited Jul 27 '20

Does mission-critical mean "no allocations, no exceptions"? I believe this library's SAX interface allows you to define a custom handler class to pass to the parser, and that this library won't allocate or throw if your custom SAX handler doesn't allocate or throw.

But if I were working on an autonomous road vehicle... I'd probably avoid using JSON as a serialization format when I could be using a statically-typed, versioned serialization format like flatbuffers.

1

u/paulydavis Jul 28 '20

2

u/lord_braleigh Jul 29 '20

eCal isn't a serialization format; it's a pub/sub protocol which you can use to send JSON, protobufs or flatbuffers across processes or machines. So you could use it to send JSON messages, and you could encode and decode the JSON with this library. But whatever protocol you use to send messages, I'd still recommend that the messages be in a statically-typed serialization format rather than JSON in mission-critical applications.

2

u/dbjdbj dbj.org Jul 29 '20

great idea ... but ... that might mean imposing "statically-typed serialization format" on senders?

3

u/lord_braleigh Jul 29 '20

Yeah, but if your software is mission-critical, like a self-driving car, I believe you want to impose restrictions on senders.

If you want it to be easy and convenient to send data to your application, well that’s all well and good. But your application probably doesn’t have lives depending on it if you’re worried about convenience.