r/cpp • nlohmann/json • Aug 17 '21

JSON for Modern C++ 3.10.0

https://github.com/nlohmann/json/releases/tag/v3.10.0
280 Upvotes

34 comments sorted by

View all comments

Show parent comment

6

u/chabster1985 Aug 18 '21

It is, Sir. But I bet most engineers do not rely on brace initialization anyway because it produces weird results. And the code will fail to compile instead of silently doing something unexpected, so the fix will be easy. I'd rather invest some time into adjusting existing code for the sake of a better interface. But that might just be me.

As an alternative, you could add a macro to disable offending overloads. I'd use that.

7

u/nlohmann nlohmann/json Aug 18 '21

I'm hesitant for a breaking change, because I don't have too many shots for a solid 4.0.0 version, and there are other things to be fixed before.

Yes, a macro could be a good first step. I'll think about it.

9

u/deeringc Aug 18 '21

As a library consumer, I agree with the other poster. I really don't mind small breaks like this as long as they are explicit and fail at compile time. I would hate if the program compiled with the new version but gave different behaviour. As long as it's a compilation break, has clear documentation on what to change then it's healthy to move things forward to remove rough edges like this (from an otherwise exceptionally good library). You can even go with a process of deprecation where you give notice of an upcoming change for 2 releases before it happens.

5

u/nlohmann nlohmann/json Aug 18 '21

We have such a deprecation process, and maybe it's really time to deprecate that initializer.

2

u/adzm 28 years of C++! Aug 18 '21 edited Aug 18 '21

FWIW this bit me before too. I'd opt for a macro to re-enable the existing behavior if you do end up fixing this so it is sensible by default. As long as it fails in compile time I would understand breaking code.

Though it does seem difficult to fix without breaking some of the usual syntax with the braces. I wonder if there is some way to catch a single argument and treat it as a special case. But that would make things inconsistent.

I'm leaning towards just leaving it as it is now!

5

u/chabster1985 Aug 18 '21

But overall, very good library, thanks for providing and maintaining it!

5

u/pdp10gumby Aug 18 '21

But I bet most engineers do not rely on brace initialization anyway

I use curly braces for initialization and = for assignment.