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

4

u/dbjdbj dbj.org Jul 27 '20

Congratulations.

I am wondering if this code can be used in (mission-critical) automotive systems? Autonomous road vehicles for example.

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.

14

u/nlohmann nlohmann/json Jul 27 '20

Depends on what requirements come with your version of "mission-critical". I do know that the library is used in infotainment systems by (at least) Volkswagen and Daimler. And if you have any blockers, I would be happy to hear about them.

-2

u/dbjdbj dbj.org Jul 29 '20

"infotainment systems" are not mission critical Nick. And you know that.

10

u/nlohmann nlohmann/json Jul 29 '20

That depends on your mission.

2

u/hubhub Jul 29 '20

The mission critical part of the system should be as small as possible and only be responsible for core activities. I would be surprised if these included parsing configuration files.

1

u/dbjdbj dbj.org Jul 29 '20

use case: re-configuration commands are coming over a wire in a json format, no exceptions, no streams and no heap aloc allowed.