🚧 made type_name() public

This commit is contained in:
Niels Lohmann 2017-01-21 16:12:17 +01:00
parent 145188f264
commit ce0b3fe5a3
5 changed files with 40 additions and 2 deletions

View file

@ -0,0 +1,24 @@
#include <json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON values
json j_null;
json j_boolean = true;
json j_number_integer = 17;
json j_number_float = 23.42;
json j_object = {{"one", 1}, {"two", 2}};
json j_array = {1, 2, 4, 8, 16};
json j_string = "Hello, world";
// call type_name()
std::cout << j_null.type_name() << '\n';
std::cout << j_boolean.type_name() << '\n';
std::cout << j_number_integer.type_name() << '\n';
std::cout << j_number_float.type_name() << '\n';
std::cout << j_object.type_name() << '\n';
std::cout << j_array.type_name() << '\n';
std::cout << j_string.type_name() << '\n';
}

View file

@ -0,0 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/V6imubWo6Lkp8gk1"><b>online</b></a>

View file

@ -0,0 +1,7 @@
null
boolean
number
number
object
array
string

View file

@ -7767,7 +7767,6 @@ class basic_json
/// @}
private:
///////////////////////////
// convenience functions //
///////////////////////////
@ -7782,6 +7781,9 @@ class basic_json
@complexity Constant.
@liveexample{The following code exemplifies `type_name()` for all JSON
types.,typename}
@since version 1.0.0
*/
std::string type_name() const
@ -7805,6 +7807,7 @@ class basic_json
}
}
private:
/*!
@brief calculates the extra space to escape a JSON string

View file

@ -7767,7 +7767,6 @@ class basic_json
/// @}
private:
///////////////////////////
// convenience functions //
///////////////////////////
@ -7782,6 +7781,9 @@ class basic_json
@complexity Constant.
@liveexample{The following code exemplifies `type_name()` for all JSON
types.,typename}
@since version 1.0.0
*/
std::string type_name() const
@ -7805,6 +7807,7 @@ class basic_json
}
}
private:
/*!
@brief calculates the extra space to escape a JSON string