address review comments
Signed-off-by: Harinath Nampally <harinath922@gmail.com>
This commit is contained in:
parent
2898659d90
commit
11165ef68d
@ -1,13 +1,6 @@
|
||||
#include <iostream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#if !defined(JSON_NOEXCEPTION) && !defined(JSON_THROW_USER) && !defined(JSON_THROW)
|
||||
#define JSON_THROW(exception) throw exception
|
||||
#else
|
||||
#include <cstdlib>
|
||||
#define JSON_THROW(exception) std::abort()
|
||||
#endif
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
namespace ns
|
||||
|
||||
@ -60,7 +60,7 @@ Other Important points:
|
||||
map will be returned when converting to or from JSON.
|
||||
- To disable the default serialization of enumerators as integers and force a compiler error instead, see [`JSON_DISABLE_ENUM_SERIALIZATION`](../api/macros/json_disable_enum_serialization.md).
|
||||
|
||||
An alternative macro [`NLOHMANN_JSON_SERIALIZE_ENUM_STRICT()` macro](../api/macros/nlohmann_json_serialize_enum.md) can be used when a more strict error handling is preffered, throwing in case of serialization errors instead of defaulting to the first enum value defined in the macro.
|
||||
An alternative macro [`NLOHMANN_JSON_SERIALIZE_ENUM_STRICT()` macro](../api/macros/nlohmann_json_serialize_enum.md) can be used when a more strict error handling is preferred, throwing in case of serialization errors instead of defaulting to the first enum value defined in the macro.
|
||||
|
||||
## Usage
|
||||
```cpp
|
||||
|
||||
@ -17,20 +17,6 @@
|
||||
|
||||
#include <nlohmann/detail/abi_macros.hpp>
|
||||
|
||||
|
||||
// exclude unsupported compilers
|
||||
#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
|
||||
#if defined(__clang__)
|
||||
#if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
|
||||
#error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
|
||||
#endif
|
||||
#elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
|
||||
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
|
||||
#error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// exclude unsupported compilers
|
||||
#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
|
||||
#if defined(__clang__)
|
||||
@ -182,6 +168,7 @@
|
||||
#define JSON_INTERNAL_CATCH(exception) catch(exception)
|
||||
#else
|
||||
#include <cstdlib>
|
||||
std::forward<T>(exception);
|
||||
#define JSON_THROW(exception) std::abort()
|
||||
#define JSON_TRY if(true)
|
||||
#define JSON_CATCH(exception) if(false)
|
||||
@ -262,7 +249,6 @@ namespace detail
|
||||
template<typename T>
|
||||
[[noreturn]] inline void json_throw_from_serialize_macro(T&& exception)
|
||||
{
|
||||
static_cast<void>(exception);
|
||||
JSON_THROW(std::forward<T>(exception));
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
@ -2383,20 +2383,6 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
// #include <nlohmann/detail/abi_macros.hpp>
|
||||
|
||||
|
||||
|
||||
// exclude unsupported compilers
|
||||
#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
|
||||
#if defined(__clang__)
|
||||
#if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
|
||||
#error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
|
||||
#endif
|
||||
#elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
|
||||
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
|
||||
#error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// exclude unsupported compilers
|
||||
#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
|
||||
#if defined(__clang__)
|
||||
@ -2548,6 +2534,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#define JSON_INTERNAL_CATCH(exception) catch(exception)
|
||||
#else
|
||||
#include <cstdlib>
|
||||
std::forward<T>(exception);
|
||||
#define JSON_THROW(exception) std::abort()
|
||||
#define JSON_TRY if(true)
|
||||
#define JSON_CATCH(exception) if(false)
|
||||
@ -2628,7 +2615,6 @@ namespace detail
|
||||
template<typename T>
|
||||
[[noreturn]] inline void json_throw_from_serialize_macro(T&& exception)
|
||||
{
|
||||
static_cast<void>(exception);
|
||||
JSON_THROW(std::forward<T>(exception));
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
Loading…
Reference in New Issue
Block a user