From a8c4f84fb89f8d7b50775e1736db84406f4cac62 Mon Sep 17 00:00:00 2001
From: Niels <niels.lohmann@gmail.com>
Date: Mon, 29 Dec 2014 16:45:54 +0100
Subject: [PATCH] + removed data() function

---
 Reference.md      | 21 +++++++++++++++++++++
 src/JSON.cc       | 13 -------------
 src/JSON.h        |  5 -----
 test/JSON_unit.cc | 24 ------------------------
 4 files changed, 21 insertions(+), 42 deletions(-)
 create mode 100644 Reference.md

diff --git a/Reference.md b/Reference.md
new file mode 100644
index 00000000..7309d5c1
--- /dev/null
+++ b/Reference.md
@@ -0,0 +1,21 @@
+# Reference
+
+## Types and default values
+
+| JSON type               | value_type                 | C++ type                      | type alias             | default value |
+| ----------------------- | -------------------------- | ----------------------------- | ---------------------- | --------------
+| null                    | `value_type::null`         | `nullptr_t`                   | -                      | `nullptr`     |
+| string                  | `value_type::string`       | `std::string`                 | `JSON::string_t`       | `""`          |
+| number (integer)        | `value_type::number`       | `int`                         | `JSON::number_t`       | `0`           |
+| number (floating point) | `value_type::number_float` | `double`                      | `JSON::number_float_t` | `0.0`         |
+| array                   | `value_type::array `       | `std::array<JSON>`            | `JSON::array_t`        | `{}`          |
+| object                  | `value_type::object`       | `std::map<std::string, JSON>` | `JSON::object_t`       | `{}`          |
+
+## Conversions
+
+There are only a few type conversions possible:
+
+- An integer number can be translated to a floating point number (e.g., by calling `get<double>()`).
+- A floating pointnnumber can be translated to an integer number (e.g., by calling `get<int>()`). Note the number is truncated and not rounded, ceiled or floored.
+- Any value but JSON objects can be translated into an array. The result is a singleton array that consists of the value before.
+- Any other conversion will throw a `std::logic_error` exception.
diff --git a/src/JSON.cc b/src/JSON.cc
index 908ff197..95b2f0c6 100644
--- a/src/JSON.cc
+++ b/src/JSON.cc
@@ -1224,19 +1224,6 @@ JSON::const_iterator JSON::find(const char* key) const
     }
 }
 
-/*!
-@return the payload of the JSON object.
-*/
-JSON::value JSON::data() noexcept
-{
-    return _value;
-}
-
-const JSON::value JSON::data() const noexcept
-{
-    return _value;
-}
-
 bool JSON::operator==(const JSON& o) const noexcept
 {
     switch (_type)
diff --git a/src/JSON.h b/src/JSON.h
index 5353baa7..dc90875f 100644
--- a/src/JSON.h
+++ b/src/JSON.h
@@ -279,11 +279,6 @@ class JSON
     /// find an element in an object (returns end() iterator otherwise)
     const_iterator find(const char*) const;
 
-    /// direct access to the underlying payload
-    value data() noexcept;
-    /// direct access to the underlying payload
-    const value data() const noexcept;
-
     /// lexicographically compares the values
     bool operator==(const JSON&) const noexcept;
     /// lexicographically compares the values
diff --git a/test/JSON_unit.cc b/test/JSON_unit.cc
index 92e5013d..92ac0d51 100644
--- a/test/JSON_unit.cc
+++ b/test/JSON_unit.cc
@@ -21,10 +21,6 @@ TEST_CASE("array")
         CHECK(j.begin() != j.end());
         CHECK(j.cbegin() != j.cend());
 
-        // check payload
-        //CHECK(*(j.data().array) == JSON::array_t());
-        //CHECK(*(j_const.data().array) == JSON::array_t());
-
         // container members
         CHECK(j.size() == 0);
         CHECK(j.empty() == true);
@@ -306,10 +302,6 @@ TEST_CASE("object")
         CHECK(j.begin() != j.end());
         CHECK(j.cbegin() != j.cend());
 
-        // check payload
-        //CHECK(*(j.data().object) == JSON::object_t());
-        //CHECK(*(j_const.data().object) == JSON::object_t());
-
         // container members
         CHECK(j.size() == 0);
         CHECK(j.empty() == true);
@@ -756,10 +748,6 @@ TEST_CASE("string")
         // string representation of default value
         CHECK(j.toString() == "\"\"");
 
-        // check payload
-        CHECK(*(j.data().string) == JSON::string_t());
-        CHECK(*(j_const.data().string) == JSON::string_t());
-
         // container members
         CHECK(j.size() == 1);
         CHECK(j.empty() == false);
@@ -842,10 +830,6 @@ TEST_CASE("boolean")
         // string representation of default value
         CHECK(j.toString() == "false");
 
-        // check payload
-        CHECK(j.data().boolean == JSON::boolean_t());
-        CHECK(j_const.data().boolean == JSON::boolean_t());
-
         // container members
         CHECK(j.size() == 1);
         CHECK(j.empty() == false);
@@ -925,10 +909,6 @@ TEST_CASE("number (int)")
         // string representation of default value
         CHECK(j.toString() == "0");
 
-        // check payload
-        CHECK(j.data().number == JSON::number_t());
-        CHECK(j_const.data().number == JSON::number_t());
-
         // container members
         CHECK(j.size() == 1);
         CHECK(j.empty() == false);
@@ -1015,10 +995,6 @@ TEST_CASE("number (float)")
         // string representation of default value
         CHECK(j.toString() == "0.000000");
 
-        // check payload
-        CHECK(j.data().number_float == JSON::number_float_t());
-        CHECK(j_const.data().number_float == JSON::number_float_t());
-
         // container members
         CHECK(j.size() == 1);
         CHECK(j.empty() == false);