json
json copied to clipboard
Change member variable from 'is' to 'is_' to avoid possible (macro) name collision
TL; DR: This pull request was attempting to addresses potential naming collisions with macros defined by users of the library. Specifically, the member variable is
in the input_adapter
class has been renamed to is_
and sb
to sb_
.
Description
we encountered issues caused by some users who came from Java/C# and defined is
as a macro in their code. This macro interfered with the library internal implementation, resulting in unexpected behavior and compilation errors due to the macro replacing variables named is
in the library's internal implementation.
I admit defining is
is very inappropriate and was a bad idea and inadvisable for them. It's the user's fault to do that and definitely out of control of this json library, however, I believe that issues caused by such keyword-like
named variables are avoidable. To prevent potential naming collisions and improve compatibility with user-defined macros, in the input_adapter
class, I
- Renamed the member variable
is
tois_
. - Renamed the member variable
sb
tosb_
(naming consistency).
Pull request checklist
- [x] The test suite compiles and runs without error.
- [x] Code coverage is 100%. Test cases can be added by editing the test suite.
- [x] The source code is amalgamated; that is, after making changes to the sources in the
include/nlohmann
directory, runmake amalgamate
to create the single-header filessingle_include/nlohmann/json.hpp
andsingle_include/nlohmann/json_fwd.hpp
. The whole process is described here.