Skip to content

Commit fec56a1

Browse files
committed
Merge branch 'release/3.10.4'
2 parents aa0e847 + a09bfa5 commit fec56a1

File tree

81 files changed

+316
-222
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+316
-222
lines changed

.github/ISSUE_TEMPLATE/Bug_report.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ assignees: ''
4747

4848
<!-- Please add an `x` to the respective line. -->
4949

50-
- [ ] latest release version 3.10.3
50+
- [ ] latest release version 3.10.4
5151
- [ ] other release - please state the version: ___
5252
- [ ] the `develop` branch
5353

CITATION.cff

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ authors:
77
88
website: https://nlohmann.me
99
title: "JSON for Modern C++"
10-
version: 3.10.3
10+
version: 3.10.4
1111
date-released: 2021
1212
license: MIT
1313
repository-code: "https://github.com/nlohmann"

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.1)
44
## PROJECT
55
## name and version
66
##
7-
project(nlohmann_json VERSION 3.10.3 LANGUAGES CXX)
7+
project(nlohmann_json VERSION 3.10.4 LANGUAGES CXX)
88

99
##
1010
## MAIN_PROJECT CHECK

ChangeLog.md

+28-12
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,35 @@
11
# Changelog
22
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
33

4-
## [3.10.3](https://github.com/nlohmann/json/releases/tag/3.10.3) (2021-10-08)
4+
## [3.10.4](https://github.com/nlohmann/json/releases/tag/3.10.4) (2021-10-16)
5+
6+
[Full Changelog](https://github.com/nlohmann/json/compare/v3.10.3...3.10.4)
7+
8+
- Compiler error in output serializer due to 'incompatible initializer' [\#3081](https://github.com/nlohmann/json/issues/3081)
9+
- Strange behaviour when using std::sort on std::vector\<json\> [\#3080](https://github.com/nlohmann/json/issues/3080)
10+
- Unhandled exception: nlohmann::detail::parse\_error [\#3078](https://github.com/nlohmann/json/issues/3078)
11+
- explicit constructor with default does not compile [\#3077](https://github.com/nlohmann/json/issues/3077)
12+
- Parse an object but get an array using GCC [\#3076](https://github.com/nlohmann/json/issues/3076)
13+
- Version 3.10.3 breaks backward-compatibility with 3.10.2 [\#3070](https://github.com/nlohmann/json/issues/3070)
14+
- Feature request, Add to\_json/from\_json to align with other to/from binary api. [\#3067](https://github.com/nlohmann/json/issues/3067)
15+
- vcpkg is out of date [\#3066](https://github.com/nlohmann/json/issues/3066)
16+
17+
- Revert invalid fix [\#3082](https://github.com/nlohmann/json/pull/3082) ([nlohmann](https://github.com/nlohmann))
18+
- Allow to use get with explicit constructor [\#3079](https://github.com/nlohmann/json/pull/3079) ([nlohmann](https://github.com/nlohmann))
19+
- fix std::filesystem::path regression [\#3073](https://github.com/nlohmann/json/pull/3073) ([theodelrieu](https://github.com/theodelrieu))
20+
- Fix Clang version [\#3040](https://github.com/nlohmann/json/pull/3040) ([nlohmann](https://github.com/nlohmann))
21+
- Fix assertion failure for JSON\_DIAGNOSTICS [\#3037](https://github.com/nlohmann/json/pull/3037) ([carlsmedstad](https://github.com/carlsmedstad))
22+
- meta: fix is\_compatible/constructible traits [\#3020](https://github.com/nlohmann/json/pull/3020) ([theodelrieu](https://github.com/theodelrieu))
23+
- Set parent pointers for values inserted via update\(\) \(fixes \#3007\). [\#3008](https://github.com/nlohmann/json/pull/3008) ([AnthonyVH](https://github.com/AnthonyVH))
24+
- Allow allocators for output\_vector\_adapter [\#2989](https://github.com/nlohmann/json/pull/2989) ([nlohmann](https://github.com/nlohmann))
25+
- Re-add Clang 12 [\#2986](https://github.com/nlohmann/json/pull/2986) ([nlohmann](https://github.com/nlohmann))
26+
- Use new Docker image [\#2981](https://github.com/nlohmann/json/pull/2981) ([nlohmann](https://github.com/nlohmann))
27+
- Fix -Wunused warnings on JSON\_DIAGNOSTICS [\#2976](https://github.com/nlohmann/json/pull/2976) ([gcerretani](https://github.com/gcerretani))
28+
- Update docset generation script [\#2967](https://github.com/nlohmann/json/pull/2967) ([nlohmann](https://github.com/nlohmann))
29+
30+
## [v3.10.3](https://github.com/nlohmann/json/releases/tag/v3.10.3) (2021-10-08)
531

6-
[Full Changelog](https://github.com/nlohmann/json/compare/v3.10.2...3.10.3)
32+
[Full Changelog](https://github.com/nlohmann/json/compare/v3.10.2...v3.10.3)
733

834
- Parsing an emtpy string returns a string with size 1 instead of expected 0 [\#3057](https://github.com/nlohmann/json/issues/3057)
935
- Linking error "duplicate symbol: std::type\_info::operator==" on static build with MinGW [\#3042](https://github.com/nlohmann/json/issues/3042)
@@ -24,16 +50,6 @@ All notable changes to this project will be documented in this file. This projec
2450
- 3.10.1 zip json.hpp has version number 3.10.0 instead of 3.10.1 [\#2973](https://github.com/nlohmann/json/issues/2973)
2551
- Assertion failure when serializing array with JSON\_DIAGNOSTICS set [\#2926](https://github.com/nlohmann/json/issues/2926)
2652

27-
- Fix Clang version [\#3040](https://github.com/nlohmann/json/pull/3040) ([nlohmann](https://github.com/nlohmann))
28-
- Fix assertion failure for JSON\_DIAGNOSTICS [\#3037](https://github.com/nlohmann/json/pull/3037) ([carlsmedstad](https://github.com/carlsmedstad))
29-
- meta: fix is\_compatible/constructible traits [\#3020](https://github.com/nlohmann/json/pull/3020) ([theodelrieu](https://github.com/theodelrieu))
30-
- Set parent pointers for values inserted via update\(\) \(fixes \#3007\). [\#3008](https://github.com/nlohmann/json/pull/3008) ([AnthonyVH](https://github.com/AnthonyVH))
31-
- Allow allocators for output\_vector\_adapter [\#2989](https://github.com/nlohmann/json/pull/2989) ([nlohmann](https://github.com/nlohmann))
32-
- Re-add Clang 12 [\#2986](https://github.com/nlohmann/json/pull/2986) ([nlohmann](https://github.com/nlohmann))
33-
- Use new Docker image [\#2981](https://github.com/nlohmann/json/pull/2981) ([nlohmann](https://github.com/nlohmann))
34-
- Fix -Wunused warnings on JSON\_DIAGNOSTICS [\#2976](https://github.com/nlohmann/json/pull/2976) ([gcerretani](https://github.com/gcerretani))
35-
- Update docset generation script [\#2967](https://github.com/nlohmann/json/pull/2967) ([nlohmann](https://github.com/nlohmann))
36-
3753
## [v3.10.2](https://github.com/nlohmann/json/releases/tag/v3.10.2) (2021-08-26)
3854

3955
[Full Changelog](https://github.com/nlohmann/json/compare/v3.10.1...v3.10.2)

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/e0d1a9d5d6fd46fcb655c4cb930bb3e8)](https://www.codacy.com/gh/nlohmann/json/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=nlohmann/json&amp;utm_campaign=Badge_Grade)
1111
[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/nlohmann/json.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/nlohmann/json/context:cpp)
1212
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/json.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:json)
13-
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/0LzTlmYG06u8qJN5)
13+
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/1mp10JbaANo6FUc7)
1414
[![Documentation](https://img.shields.io/badge/docs-doxygen-blue.svg)](https://nlohmann.github.io/json/doxygen/index.html)
1515
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nlohmann/json/master/LICENSE.MIT)
1616
[![GitHub Releases](https://img.shields.io/github/release/nlohmann/json.svg)](https://github.com/nlohmann/json/releases)
@@ -1628,7 +1628,7 @@ The library itself consists of a single header file licensed under the MIT licen
16281628
- [**send_to_wandbox**](https://github.com/nlohmann/json/blob/develop/doc/scripts/send_to_wandbox.py) to send code examples to [Wandbox](https://wandbox.org)
16291629
- [**Travis**](https://travis-ci.org) for [continuous integration](https://travis-ci.org/nlohmann/json) on Linux and macOS
16301630
- [**Valgrind**](https://valgrind.org) to check for correct memory management
1631-
- [**Wandbox**](https://wandbox.org) for [online examples](https://wandbox.org/permlink/0LzTlmYG06u8qJN5)
1631+
- [**Wandbox**](https://wandbox.org) for [online examples](https://wandbox.org/permlink/1mp10JbaANo6FUc7)
16321632

16331633

16341634
## Projects using JSON for Modern C++

doc/Doxyfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#---------------------------------------------------------------------------
66
DOXYFILE_ENCODING = UTF-8
77
PROJECT_NAME = "JSON for Modern C++"
8-
PROJECT_NUMBER = 3.10.3
8+
PROJECT_NUMBER = 3.10.4
99
PROJECT_BRIEF =
1010
PROJECT_LOGO =
1111
OUTPUT_DIRECTORY = .

doc/examples/README.link

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<a target="_blank" href="https://wandbox.org/permlink/0LzTlmYG06u8qJN5"><b>online</b></a>
1+
<a target="_blank" href="https://wandbox.org/permlink/1mp10JbaANo6FUc7"><b>online</b></a>

doc/examples/meta.output

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"version": {
1212
"major": 3,
1313
"minor": 10,
14-
"patch": 3,
15-
"string": "3.10.3"
14+
"patch": 4,
15+
"string": "3.10.4"
1616
}
1717
}

doc/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,4 +332,4 @@ Note that this table only lists those exceptions thrown due to the type. For ins
332332
@author [Niels Lohmann](http://nlohmann.me)
333333
@see https://github.com/nlohmann/json to download the source code
334334

335-
@version 3.10.3
335+
@version 3.10.4

doc/json.gif

-72 Bytes
Loading

include/nlohmann/detail/conversions/from_json.hpp

+17-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#include <nlohmann/detail/meta/type_traits.hpp>
2020
#include <nlohmann/detail/value_t.hpp>
2121

22+
#ifdef JSON_HAS_CPP_17
23+
#include <filesystem>
24+
#endif
25+
2226
namespace nlohmann
2327
{
2428
namespace detail
@@ -169,7 +173,7 @@ void from_json(const BasicJsonType& j, std::valarray<T>& l)
169173
}
170174

171175
template<typename BasicJsonType, typename T, std::size_t N>
172-
auto from_json(const BasicJsonType& j, T (&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
176+
auto from_json(const BasicJsonType& j, T (&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
173177
-> decltype(j.template get<T>(), void())
174178
{
175179
for (std::size_t i = 0; i < N; ++i)
@@ -444,6 +448,18 @@ void from_json(const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyE
444448
}
445449
}
446450

451+
#ifdef JSON_HAS_CPP_17
452+
template<typename BasicJsonType>
453+
void from_json(const BasicJsonType& j, std::filesystem::path& p)
454+
{
455+
if (JSON_HEDLEY_UNLIKELY(!j.is_string()))
456+
{
457+
JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j));
458+
}
459+
p = *j.template get_ptr<const typename BasicJsonType::string_t*>();
460+
}
461+
#endif
462+
447463
struct from_json_fn
448464
{
449465
template<typename BasicJsonType, typename T>

include/nlohmann/detail/conversions/to_json.hpp

+13
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@
99
#include <valarray> // valarray
1010
#include <vector> // vector
1111

12+
#include <nlohmann/detail/macro_scope.hpp>
1213
#include <nlohmann/detail/iterators/iteration_proxy.hpp>
1314
#include <nlohmann/detail/meta/cpp_future.hpp>
1415
#include <nlohmann/detail/meta/type_traits.hpp>
1516
#include <nlohmann/detail/value_t.hpp>
1617

18+
#ifdef JSON_HAS_CPP_17
19+
#include <filesystem>
20+
#endif
21+
1722
namespace nlohmann
1823
{
1924
namespace detail
@@ -386,6 +391,14 @@ void to_json(BasicJsonType& j, const T& t)
386391
to_json_tuple_impl(j, t, make_index_sequence<std::tuple_size<T>::value> {});
387392
}
388393

394+
#ifdef JSON_HAS_CPP_17
395+
template<typename BasicJsonType>
396+
void to_json(BasicJsonType& j, const std::filesystem::path& p)
397+
{
398+
j = p.string();
399+
}
400+
#endif
401+
389402
struct to_json_fn
390403
{
391404
template<typename BasicJsonType, typename T>

include/nlohmann/detail/meta/type_traits.hpp

+11-28
Original file line numberDiff line numberDiff line change
@@ -309,44 +309,21 @@ struct is_constructible_object_type
309309
: is_constructible_object_type_impl<BasicJsonType,
310310
ConstructibleObjectType> {};
311311

312-
template<typename BasicJsonType, typename CompatibleStringType,
313-
typename = void>
314-
struct is_compatible_string_type_impl : std::false_type {};
315-
316312
template<typename BasicJsonType, typename CompatibleStringType>
317-
struct is_compatible_string_type_impl <
318-
BasicJsonType, CompatibleStringType,
319-
enable_if_t<is_detected_convertible<typename BasicJsonType::string_t::value_type,
320-
range_value_t,
321-
CompatibleStringType>::value >>
313+
struct is_compatible_string_type
322314
{
323315
static constexpr auto value =
324316
is_constructible<typename BasicJsonType::string_t, CompatibleStringType>::value;
325317
};
326318

327319
template<typename BasicJsonType, typename ConstructibleStringType>
328-
struct is_compatible_string_type
329-
: is_compatible_string_type_impl<BasicJsonType, ConstructibleStringType> {};
330-
331-
template<typename BasicJsonType, typename ConstructibleStringType,
332-
typename = void>
333-
struct is_constructible_string_type_impl : std::false_type {};
334-
335-
template<typename BasicJsonType, typename ConstructibleStringType>
336-
struct is_constructible_string_type_impl <
337-
BasicJsonType, ConstructibleStringType,
338-
enable_if_t<is_detected_exact<typename BasicJsonType::string_t::value_type,
339-
value_type_t, ConstructibleStringType>::value >>
320+
struct is_constructible_string_type
340321
{
341322
static constexpr auto value =
342323
is_constructible<ConstructibleStringType,
343324
typename BasicJsonType::string_t>::value;
344325
};
345326

346-
template<typename BasicJsonType, typename ConstructibleStringType>
347-
struct is_constructible_string_type
348-
: is_constructible_string_type_impl<BasicJsonType, ConstructibleStringType> {};
349-
350327
template<typename BasicJsonType, typename CompatibleArrayType, typename = void>
351328
struct is_compatible_array_type_impl : std::false_type {};
352329

@@ -355,7 +332,10 @@ struct is_compatible_array_type_impl <
355332
BasicJsonType, CompatibleArrayType,
356333
enable_if_t <
357334
is_detected<iterator_t, CompatibleArrayType>::value&&
358-
is_iterator_traits<iterator_traits<detected_t<iterator_t, CompatibleArrayType>>>::value >>
335+
is_iterator_traits<iterator_traits<detected_t<iterator_t, CompatibleArrayType>>>::value&&
336+
// special case for types like std::filesystem::path whose iterator's value_type are themselves
337+
// c.f. https://github.com/nlohmann/json/pull/3073
338+
!std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>::value >>
359339
{
360340
static constexpr bool value =
361341
is_constructible<BasicJsonType,
@@ -388,8 +368,11 @@ struct is_constructible_array_type_impl <
388368
is_detected<iterator_t, ConstructibleArrayType>::value&&
389369
is_iterator_traits<iterator_traits<detected_t<iterator_t, ConstructibleArrayType>>>::value&&
390370
is_detected<range_value_t, ConstructibleArrayType>::value&&
391-
is_complete_type <
392-
detected_t<range_value_t, ConstructibleArrayType >>::value >>
371+
// special case for types like std::filesystem::path whose iterator's value_type are themselves
372+
// c.f. https://github.com/nlohmann/json/pull/3073
373+
!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>::value&&
374+
is_complete_type <
375+
detected_t<range_value_t, ConstructibleArrayType >>::value >>
393376
{
394377
using value_type = range_value_t<ConstructibleArrayType>;
395378

include/nlohmann/detail/output/serializer.hpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -811,8 +811,8 @@ class serializer
811811
// erase thousands separator
812812
if (thousands_sep != '\0')
813813
{
814-
auto* const end = std::remove(number_buffer.begin(),
815-
number_buffer.begin() + len, thousands_sep);
814+
// NOLINTNEXTLINE(readability-qualified-auto,llvm-qualified-auto): std::remove returns an iterator, see https://github.com/nlohmann/json/issues/3081
815+
const auto end = std::remove(number_buffer.begin(), number_buffer.begin() + len, thousands_sep);
816816
std::fill(end, number_buffer.end(), '\0');
817817
JSON_ASSERT((end - number_buffer.begin()) <= len);
818818
len = (end - number_buffer.begin());
@@ -821,7 +821,8 @@ class serializer
821821
// convert decimal point to '.'
822822
if (decimal_point != '\0' && decimal_point != '.')
823823
{
824-
auto* const dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
824+
// NOLINTNEXTLINE(readability-qualified-auto,llvm-qualified-auto): std::find returns an iterator, see https://github.com/nlohmann/json/issues/3081
825+
const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
825826
if (dec_pos != number_buffer.end())
826827
{
827828
*dec_pos = '.';

include/nlohmann/json.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
__ _____ _____ _____
33
__| | __| | | | JSON for Modern C++
4-
| | |__ | | | | | | version 3.10.3
4+
| | |__ | | | | | | version 3.10.4
55
|_____|_____|_____|_|___| https://github.com/nlohmann/json
66
77
Licensed under the MIT License <http://opensource.org/licenses/MIT>.
@@ -32,7 +32,7 @@ SOFTWARE.
3232

3333
#define NLOHMANN_JSON_VERSION_MAJOR 3
3434
#define NLOHMANN_JSON_VERSION_MINOR 10
35-
#define NLOHMANN_JSON_VERSION_PATCH 3
35+
#define NLOHMANN_JSON_VERSION_PATCH 4
3636

3737
#include <algorithm> // all_of, find, for_each
3838
#include <cstddef> // nullptr_t, ptrdiff_t, size_t
@@ -1065,7 +1065,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
10651065
object = nullptr; // silence warning, see #821
10661066
if (JSON_HEDLEY_UNLIKELY(t == value_t::null))
10671067
{
1068-
JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.10.3", basic_json())); // LCOV_EXCL_LINE
1068+
JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.10.4", basic_json())); // LCOV_EXCL_LINE
10691069
}
10701070
break;
10711071
}
@@ -3069,7 +3069,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
30693069
ValueType get_impl(detail::priority_tag<0> /*unused*/) const noexcept(noexcept(
30703070
JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
30713071
{
3072-
ValueType ret{};
3072+
auto ret = ValueType();
30733073
JSONSerializer<ValueType>::from_json(*this, ret);
30743074
return ret;
30753075
}

meson.build

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
project('nlohmann_json',
22
'cpp',
3-
version : '3.10.3',
3+
version : '3.10.4',
44
license : 'MIT',
55
)
66

0 commit comments

Comments
 (0)