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
I was working on a project for my professor when 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 to is_.
Renamed the member variable sb to sb_ (naming consistency).
This is similar to the practice in the C++ standard library, which avoids using common words as variable names and instead uses names with underscores to minimize naming collisions. Although I don't believe changes were necessary in unit_regression.cpp in tests folder, I applied the same renaming for consistency.
As a freshman at university, I'm not sure whether this is actually an issue yet. If it isn't as important as I thought, sorry for bothering!
^^^^^ note: Windows and MacOS workflow went well. But there had been 80k+ warnings on ubuntu workflow relating to clang-tidy and inline keyword. definitely it's not my part which caused that.
[x] The source code is amalgamated; that is, after making changes to the sources in the include/nlohmann directory, run make amalgamate to create the single-header files single_include/nlohmann/json.hpp and single_include/nlohmann/json_fwd.hpp. The whole process is described here.
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 theinput_adapter
class has been renamed tois_
andsb
tosb_
.Description
I was working on a project for my professor when 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 namedis
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 suchkeyword-like
named variables are avoidable. To prevent potential naming collisions and improve compatibility with user-defined macros, in theinput_adapter
class, Iis
tois_
.sb
tosb_
(naming consistency).This is similar to the practice in the C++ standard library, which avoids using common words as variable names and instead uses names with underscores to minimize naming collisions. Although I don't believe changes were necessary in
unit_regression.cpp
intests
folder, I applied the same renaming for consistency.As a freshman at university, I'm not sure whether this is actually an issue yet. If it isn't as important as I thought, sorry for bothering!
Pull request checklist
[x] The test suite compiles and runs without error.
^^^^^ note: Windows and MacOS workflow went well. But there had been 80k+ warnings on
ubuntu
workflow relating to clang-tidy andinline
keyword. definitely it's not my part which caused that.[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.