Skip to content

Commit 26f4f68

Browse files
authoredMar 26, 2025
fix actions fails
1 parent 01f60ae commit 26f4f68

File tree

1 file changed

+11
-12
lines changed
  • include/jwt-cpp/traits/danielaparker-jsoncons

1 file changed

+11
-12
lines changed
 

‎include/jwt-cpp/traits/danielaparker-jsoncons/traits.h

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#define JWT_DISABLE_PICOJSON
55
#define JSONCONS_NO_DEPRECATED
66

7-
#include "jwt-cpp/jwt.h"
87
#include "jsoncons/json.hpp"
8+
#include "jwt-cpp/jwt.h"
99

1010
#include <sstream>
1111

@@ -17,7 +17,8 @@ namespace jwt {
1717
/// basic_claim's JSON trait implementation for jsoncons.
1818
struct danielaparker_jsoncons {
1919
// 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!");
2122

2223
using json = jsoncons::json;
2324
using value_type = json;
@@ -47,7 +48,7 @@ namespace jwt {
4748
}
4849

4950
// 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]; }
5152

5253
// Add missing C++11 element access
5354
const mapped_type& at(const key_type& key) const { return json_.at(key); }
@@ -95,7 +96,7 @@ namespace jwt {
9596
return *this;
9697
}
9798

98-
value_type& operator[](size_type index) { return const_cast<value_type&>(json_[index]); }
99+
value_type& operator[](size_type index) { return json_[index]; }
99100

100101
const value_type& at(size_type index) const { return json_.at(index); }
101102

@@ -179,20 +180,19 @@ namespace jwt {
179180
} // namespace jwt
180181

181182
namespace jsoncons {
182-
template <typename Json>
183+
template<typename Json>
183184
struct json_type_traits<Json, jwt::traits::danielaparker_jsoncons::object_type> {
184185

185186
using allocator_type = typename Json::allocator_type;
186187

187-
static bool is(const Json&) noexcept {
188-
return true;
189-
}
188+
static bool is(const Json&) noexcept { return true; }
190189

191190
static jwt::traits::danielaparker_jsoncons::object_type as(const Json& j) {
192191
jwt::traits::danielaparker_jsoncons::object_type o;
193192
for (const auto& item : j.object_range()) {
194193
o[item.key()] = item.value();
195194
}
195+
return o;
196196
}
197197

198198
static Json to_json(const jwt::traits::danielaparker_jsoncons::object_type& val) {
@@ -208,20 +208,19 @@ namespace jsoncons {
208208
}
209209
};
210210

211-
template <typename Json>
211+
template<typename Json>
212212
struct json_type_traits<Json, jwt::traits::danielaparker_jsoncons::array_type> {
213213

214214
using allocator_type = typename Json::allocator_type;
215215

216-
static bool is(const Json&) noexcept {
217-
return true;
218-
}
216+
static bool is(const Json&) noexcept { return true; }
219217

220218
static jwt::traits::danielaparker_jsoncons::array_type as(const Json& j) {
221219
jwt::traits::danielaparker_jsoncons::array_type a;
222220
for (const auto& item : j.array_range()) {
223221
a.push_back(item);
224222
}
223+
return a;
225224
}
226225

227226
static Json to_json(const jwt::traits::danielaparker_jsoncons::array_type& val) {

0 commit comments

Comments
 (0)
Failed to load comments.