4
4
#define JWT_DISABLE_PICOJSON
5
5
#define JSONCONS_NO_DEPRECATED
6
6
7
- #include " jwt-cpp/jwt.h"
8
7
#include " jsoncons/json.hpp"
8
+ #include " jwt-cpp/jwt.h"
9
9
10
10
#include < sstream>
11
11
@@ -17,7 +17,8 @@ namespace jwt {
17
17
// / basic_claim's JSON trait implementation for jsoncons.
18
18
struct danielaparker_jsoncons {
19
19
// Needs at least https://github.com/danielaparker/jsoncons/commit/28c56b90ec7337f98a5b8942574590111a5e5831
20
- static_assert (jsoncons::version().minor >= 167 || (jsoncons::version().major > 0 ), " A higher version of jsoncons is required!" );
20
+ static_assert (jsoncons::version().minor >= 167 || (jsoncons::version().major > 0 ),
21
+ " A higher version of jsoncons is required!" );
21
22
22
23
using json = jsoncons::json;
23
24
using value_type = json;
@@ -47,7 +48,7 @@ namespace jwt {
47
48
}
48
49
49
50
// Add missing C++11 subscription operator
50
- mapped_type& operator [](const key_type& key) { return const_cast <mapped_type&>( json_[key]) ; }
51
+ mapped_type& operator [](const key_type& key) { return json_[key]; }
51
52
52
53
// Add missing C++11 element access
53
54
const mapped_type& at (const key_type& key) const { return json_.at (key); }
@@ -95,7 +96,7 @@ namespace jwt {
95
96
return *this ;
96
97
}
97
98
98
- value_type& operator [](size_type index) { return const_cast <value_type&>( json_[index]) ; }
99
+ value_type& operator [](size_type index) { return json_[index]; }
99
100
100
101
const value_type& at (size_type index) const { return json_.at (index); }
101
102
@@ -179,20 +180,19 @@ namespace jwt {
179
180
} // namespace jwt
180
181
181
182
namespace jsoncons {
182
- template <typename Json>
183
+ template <typename Json>
183
184
struct json_type_traits <Json, jwt::traits::danielaparker_jsoncons::object_type> {
184
185
185
186
using allocator_type = typename Json::allocator_type;
186
187
187
- static bool is (const Json&) noexcept {
188
- return true ;
189
- }
188
+ static bool is (const Json&) noexcept { return true ; }
190
189
191
190
static jwt::traits::danielaparker_jsoncons::object_type as (const Json& j) {
192
191
jwt::traits::danielaparker_jsoncons::object_type o;
193
192
for (const auto & item : j.object_range ()) {
194
193
o[item.key ()] = item.value ();
195
194
}
195
+ return o;
196
196
}
197
197
198
198
static Json to_json (const jwt::traits::danielaparker_jsoncons::object_type& val) {
@@ -208,20 +208,19 @@ namespace jsoncons {
208
208
}
209
209
};
210
210
211
- template <typename Json>
211
+ template <typename Json>
212
212
struct json_type_traits <Json, jwt::traits::danielaparker_jsoncons::array_type> {
213
213
214
214
using allocator_type = typename Json::allocator_type;
215
215
216
- static bool is (const Json&) noexcept {
217
- return true ;
218
- }
216
+ static bool is (const Json&) noexcept { return true ; }
219
217
220
218
static jwt::traits::danielaparker_jsoncons::array_type as (const Json& j) {
221
219
jwt::traits::danielaparker_jsoncons::array_type a;
222
220
for (const auto & item : j.array_range ()) {
223
221
a.push_back (item);
224
222
}
223
+ return a;
225
224
}
226
225
227
226
static Json to_json (const jwt::traits::danielaparker_jsoncons::array_type& val) {
0 commit comments