nlohmann提供了成员函数type(),用于返回当前的json数据类型:文章来源:https://www.toymoban.com/news/detail-645003.html
constexpr value_t type() const noexcept
{
return m_type;
}
using value_t = detail::value_t;
enum class value_t : std::uint8_t
{
null, ///< null value
object, ///< object (unordered set of name/value pairs)
array, ///< array (ordered collection of values)
string, ///< string value
boolean, ///< boolean value
number_integer, ///< number value (signed integer)
number_unsigned, ///< number value (unsigned integer)
number_float, ///< number value (floating-point)
binary, ///< binary array (ordered collection of bytes)
discarded ///< discarded by the parser callback function
};
可以根据type进行类型检查:文章来源地址https://www.toymoban.com/news/detail-645003.html
#include <iostream>
#include <nlohmann/json.hpp>
using namespace std;
using js
到了这里,关于nlohmann json:类型检查的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!