@@ -1243,34 +1243,34 @@ has_can_convert = ext_traits::is_detected<traits_can_convert_t, Json, T>;
12431243 };
12441244
12451245 template <typename Json,typename T>
1246- struct json_conv_traits <Json, jsoncons::optional<T> ,
1247- typename std::enable_if<!is_json_conv_traits_declared< jsoncons::optional <T>>::value>::type>
1246+ struct json_conv_traits <Json, T ,
1247+ typename std::enable_if<jsoncons::ext_traits::is_optional <T>::value && !is_json_conv_traits_declared<T >::value>::type>
12481248 {
12491249 public:
1250- using result_type = conversion_result<jsoncons::optional<T> >;
1250+ using result_type = conversion_result<T >;
12511251
12521252 static bool is (const Json& j) noexcept
12531253 {
1254- return j.is_null () || j.template is <T >();
1254+ return j.is_null () || j.template is <typename T::value_type >();
12551255 }
12561256
12571257 template <typename Alloc, typename TempAlloc>
12581258 static result_type try_as (const allocator_set<Alloc,TempAlloc>& aset, const Json& j)
12591259 {
12601260 if (j.is_null ())
12611261 {
1262- return result_type (jsoncons::optional<T> ());
1262+ return result_type (T ());
12631263 }
1264- auto r = j.template try_as <T >(aset);
1264+ auto r = j.template try_as <typename T::value_type >(aset);
12651265 if (!r)
12661266 {
12671267 return result_type (jsoncons::unexpect, r.error ());
12681268 }
1269- return result_type (jsoncons::optional<T> (std::move (r.value ())));
1269+ return result_type (T (std::move (r.value ())));
12701270 }
12711271
12721272 template <typename Alloc, typename TempAlloc>
1273- static Json to_json (const allocator_set<Alloc,TempAlloc>& aset, const jsoncons::optional<T> & val)
1273+ static Json to_json (const allocator_set<Alloc,TempAlloc>& aset, const T & val)
12741274 {
12751275 return val.has_value () ? jsoncons::make_obj_using_allocator<Json>(aset.get_allocator (), *val) : Json::null ();
12761276 }
0 commit comments