diff --git a/include/json/config.h b/include/json/config.h index 6971fa656..4619e93bd 100644 --- a/include/json/config.h +++ b/include/json/config.h @@ -105,6 +105,7 @@ extern JSON_API int msvc_pre1900_c99_snprintf(char* outBuf, size_t size, #endif // if !defined(JSON_IS_AMALGAMATION) namespace Json { +JSON_API const char* version(); using Int = int; using UInt = unsigned int; #if defined(JSON_NO_INT64) diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp index a812ea4d3..168251ee1 100644 --- a/src/lib_json/json_value.cpp +++ b/src/lib_json/json_value.cpp @@ -1704,4 +1704,6 @@ Value& Path::make(Value& root) const { return *node; } +const char* version() { return JSONCPP_VERSION_STRING; } + } // namespace Json diff --git a/src/test_lib_json/main.cpp b/src/test_lib_json/main.cpp index d6938c1d0..4c000fa9b 100644 --- a/src/test_lib_json/main.cpp +++ b/src/test_lib_json/main.cpp @@ -4188,6 +4188,11 @@ JSONTEST_FIXTURE_LOCAL(VersionTest, VersionNumbersMatch) { JSONTEST_ASSERT_EQUAL(vstr.str(), std::string(JSONCPP_VERSION_STRING)); } +JSONTEST_FIXTURE_LOCAL(VersionTest, RuntimeVersionString) { + JSONTEST_ASSERT_EQUAL(std::string(JSONCPP_VERSION_STRING), + std::string(Json::version())); +} + #if defined(__GNUC__) #pragma GCC diagnostic pop #endif