Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
json
Commits
32bda1a7
Unverified
Commit
32bda1a7
authored
Jun 04, 2020
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Plain Diff
Merge branches 'develop' and 'mkdocs' of
https://github.com/nlohmann/json
into mkdocs
parents
e3d9b3d7
92125907
Changes
19
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
409 additions
and
276 deletions
+409
-276
.circleci/config.yml
.circleci/config.yml
+2
-8
.github/ISSUE_TEMPLATE/Feature_request.md
.github/ISSUE_TEMPLATE/Feature_request.md
+0
-1
.github/ISSUE_TEMPLATE/question.md
.github/ISSUE_TEMPLATE/question.md
+6
-0
.github/workflows/macos.yml
.github/workflows/macos.yml
+1
-1
.github/workflows/ubuntu.yml
.github/workflows/ubuntu.yml
+1
-1
.github/workflows/windows.yml
.github/workflows/windows.yml
+1
-1
.travis.yml
.travis.yml
+1
-5
Makefile
Makefile
+259
-223
README.md
README.md
+55
-25
appveyor.yml
appveyor.yml
+1
-1
doc/avatars.png
doc/avatars.png
+0
-0
include/nlohmann/detail/input/input_adapters.hpp
include/nlohmann/detail/input/input_adapters.hpp
+3
-2
include/nlohmann/detail/input/json_sax.hpp
include/nlohmann/detail/input/json_sax.hpp
+1
-1
include/nlohmann/detail/input/lexer.hpp
include/nlohmann/detail/input/lexer.hpp
+1
-1
include/nlohmann/json.hpp
include/nlohmann/json.hpp
+1
-1
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+6
-5
test/CMakeLists.txt
test/CMakeLists.txt
+1
-0
test/src/unit-class_parser.cpp
test/src/unit-class_parser.cpp
+47
-0
test/src/unit-regression.cpp
test/src/unit-regression.cpp
+22
-0
No files found.
.circleci/config.yml
View file @
32bda1a7
...
...
@@ -10,12 +10,9 @@ jobs:
-
run
:
name
:
Install required tools
command
:
'
apt-get
update
&&
apt-get
install
-y
gcc
g++
git
cmake'
-
run
:
name
:
Show versions
command
:
'
g++
--version
;
uname
-a;
cmake
--version'
-
run
:
name
:
Run CMake
command
:
'
mkdir
build
;
cd
build
;
cmake
..'
command
:
'
mkdir
build
;
cd
build
;
cmake
..
-DJSON_BuildTests=On
'
-
run
:
name
:
Compile
command
:
'
cmake
--build
build'
...
...
@@ -33,12 +30,9 @@ jobs:
-
run
:
name
:
Install required tools
command
:
'
pacman
-Sy
--noconfirm
base
base-devel
gcc
git
cmake'
-
run
:
name
:
Show versions
command
:
'
g++
--version
;
uname
-a;
cmake
--version'
-
run
:
name
:
Run CMake
command
:
'
mkdir
build
;
cd
build
;
cmake
..'
command
:
'
mkdir
build
;
cd
build
;
cmake
..
-DJSON_BuildTests=On
'
-
run
:
name
:
Compile
command
:
'
cmake
--build
build'
...
...
.github/ISSUE_TEMPLATE/Feature_request.md
View file @
32bda1a7
...
...
@@ -14,4 +14,3 @@ assignees: ''
#### How would the feature be usable for other users?
<!-- Include sample usage where appropriate. -->
.github/ISSUE_TEMPLATE/question.md
View file @
32bda1a7
...
...
@@ -7,6 +7,8 @@ assignees: ''
---
<!-- Provide a concise summary of the issue in the title above. -->
#### What do you want to achieve?
<!-- Please describe the feature as detailed as possible. -->
...
...
@@ -17,6 +19,10 @@ assignees: ''
<!-- There is a full documentation of the API: https://nlohmann.github.io/json/ -->
<!-- There is a detailed README file: https://github.com/nlohmann/json/blob/develop/README.md -->
#### Can you provide a small code example?
<!-- Please understand that we cannot analyze and debug large code bases. -->
#### Which compiler and operating system are you using?
<!-- Include as many relevant details about the environment you experienced the bug in. -->
...
...
.github/workflows/macos.yml
View file @
32bda1a7
...
...
@@ -10,7 +10,7 @@ jobs:
steps
:
-
uses
:
actions/checkout@v1
-
name
:
cmake
run
:
cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug
run
:
cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug
-DJSON_BuildTests=On
-
name
:
build
run
:
cmake --build build --parallel
10
-
name
:
test
...
...
.github/workflows/ubuntu.yml
View file @
32bda1a7
...
...
@@ -10,7 +10,7 @@ jobs:
steps
:
-
uses
:
actions/checkout@v1
-
name
:
cmake
run
:
cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug
run
:
cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug
-DJSON_BuildTests=On
-
name
:
build
run
:
cmake --build build --parallel
10
-
name
:
test
...
...
.github/workflows/windows.yml
View file @
32bda1a7
...
...
@@ -10,7 +10,7 @@ jobs:
steps
:
-
uses
:
actions/checkout@v1
-
name
:
cmake
run
:
cmake -S . -B build -G "Visual Studio 16 2019" -D CMAKE_BUILD_TYPE=Debug
run
:
cmake -S . -B build -G "Visual Studio 16 2019" -D CMAKE_BUILD_TYPE=Debug
-DJSON_BuildTests=On
-
name
:
build
run
:
cmake --build build --parallel
10
-
name
:
test
...
...
.travis.yml
View file @
32bda1a7
...
...
@@ -321,13 +321,9 @@ script:
# by default, use the single-header version
-
if [[ "${MULTIPLE_HEADERS}" == "" ]]; then export MULTIPLE_HEADERS=OFF; fi
# show OS/compiler version
-
uname -a
-
$CXX --version
# compile and execute unit tests
-
mkdir -p build && cd build
-
cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -GNinja && cmake --build . --config Release
-
cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -
DJSON_BuildTests=On -
GNinja && cmake --build . --config Release
-
ctest -C Release --timeout 2700 -V -j
-
cd ..
...
...
Makefile
View file @
32bda1a7
This diff is collapsed.
Click to expand it.
README.md
View file @
32bda1a7
This diff is collapsed.
Click to expand it.
appveyor.yml
View file @
32bda1a7
...
...
@@ -112,7 +112,7 @@ before_build:
# for with_win_header build, inject the inclusion of Windows.h to the single-header library
-
ps
:
if ($env:name -Eq "with_win_header") { $header_path = "single_include\nlohmann\json.hpp" }
-
ps
:
if ($env:name -Eq "with_win_header") { "#include <Windows.h>`n" + (Get-Content $header_path | Out-String) | Set-Content $header_path }
-
if "%GENERATOR%"=="Ninja" (cmake . -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%configuration%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin"
) else (cmake . -G "%GENERATOR%" -A "%GENERATOR_PLATFORM%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin"
)
-
if "%GENERATOR%"=="Ninja" (cmake . -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%configuration%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin"
-DJSON_BuildTests=On) else (cmake . -G "%GENERATOR%" -A "%GENERATOR_PLATFORM%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" -DJSON_BuildTests=On
)
build_script
:
-
cmake --build . --config "%configuration%"
...
...
doc/avatars.png
View replaced file @
e3d9b3d7
View file @
32bda1a7
1.01 MB
|
W:
|
H:
1.11 MB
|
W:
|
H:
2-up
Swipe
Onion skin
include/nlohmann/detail/input/input_adapters.hpp
View file @
32bda1a7
...
...
@@ -331,13 +331,14 @@ inline input_stream_adapter input_adapter(std::istream&& stream)
return
input_stream_adapter
(
stream
);
}
template
<
typename
CharT
,
template
<
typename
CharT
,
typename
SizeT
,
typename
std
::
enable_if
<
std
::
is_pointer
<
CharT
>
::
value
and
std
::
is_integral
<
typename
std
::
remove_pointer
<
CharT
>::
type
>::
value
and
not
std
::
is_same
<
SizeT
,
bool
>::
value
and
sizeof
(
typename
std
::
remove_pointer
<
CharT
>::
type
)
==
1
,
int
>::
type
=
0
>
input_buffer_adapter
input_adapter
(
CharT
b
,
std
::
size_t
l
)
input_buffer_adapter
input_adapter
(
CharT
b
,
SizeT
l
)
{
return
input_buffer_adapter
(
reinterpret_cast
<
const
char
*>
(
b
),
l
);
}
...
...
include/nlohmann/detail/input/json_sax.hpp
View file @
32bda1a7
...
...
@@ -452,7 +452,7 @@ class json_sax_dom_callback_parser
ref_stack
.
pop_back
();
keep_stack
.
pop_back
();
if
(
not
ref_stack
.
empty
()
and
ref_stack
.
back
()
and
ref_stack
.
back
()
->
is_
object
())
if
(
not
ref_stack
.
empty
()
and
ref_stack
.
back
()
and
ref_stack
.
back
()
->
is_
structured
())
{
// remove discarded value
for
(
auto
it
=
ref_stack
.
back
()
->
begin
();
it
!=
ref_stack
.
back
()
->
end
();
++
it
)
...
...
include/nlohmann/detail/input/lexer.hpp
View file @
32bda1a7
...
...
@@ -1367,7 +1367,7 @@ scan_number_done:
std
::
string
result
;
for
(
const
auto
c
:
token_string
)
{
if
(
'\x00'
<=
c
and
c
<=
'\x1F'
)
if
(
static_cast
<
unsigned
char
>
(
c
)
<=
'\x1F'
)
{
// escape control characters
std
::
array
<
char
,
9
>
cs
{{}};
...
...
include/nlohmann/json.hpp
View file @
32bda1a7
...
...
@@ -3207,7 +3207,7 @@ class basic_json
not
std
::
is_same
<
ValueType
,
typename
string_t
::
value_type
>::
value
and
not
detail
::
is_basic_json
<
ValueType
>::
value
and
not
std
::
is_same
<
ValueType
,
std
::
initializer_list
<
typename
string_t
::
value_type
>>::
value
#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) and _MSC_VER <= 1914))
#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) and _MSC_VER
>= 1910 and _MSC_VER
<= 1914))
and
not
std
::
is_same
<
ValueType
,
typename
std
::
string_view
>::
value
#endif
and
detail
::
is_detected
<
detail
::
get_template_function
,
const
basic_json_t
&
,
ValueType
>::
value
...
...
single_include/nlohmann/json.hpp
View file @
32bda1a7
...
...
@@ -4753,13 +4753,14 @@ inline input_stream_adapter input_adapter(std::istream&& stream)
return
input_stream_adapter
(
stream
);
}
template
<
typename
CharT
,
template
<
typename
CharT
,
typename
SizeT
,
typename
std
::
enable_if
<
std
::
is_pointer
<
CharT
>
::
value
and
std
::
is_integral
<
typename
std
::
remove_pointer
<
CharT
>::
type
>::
value
and
not
std
::
is_same
<
SizeT
,
bool
>::
value
and
sizeof
(
typename
std
::
remove_pointer
<
CharT
>::
type
)
==
1
,
int
>::
type
=
0
>
input_buffer_adapter
input_adapter
(
CharT
b
,
std
::
size_t
l
)
input_buffer_adapter
input_adapter
(
CharT
b
,
SizeT
l
)
{
return
input_buffer_adapter
(
reinterpret_cast
<
const
char
*>
(
b
),
l
);
}
...
...
@@ -5357,7 +5358,7 @@ class json_sax_dom_callback_parser
ref_stack
.
pop_back
();
keep_stack
.
pop_back
();
if
(
not
ref_stack
.
empty
()
and
ref_stack
.
back
()
and
ref_stack
.
back
()
->
is_
object
())
if
(
not
ref_stack
.
empty
()
and
ref_stack
.
back
()
and
ref_stack
.
back
()
->
is_
structured
())
{
// remove discarded value
for
(
auto
it
=
ref_stack
.
back
()
->
begin
();
it
!=
ref_stack
.
back
()
->
end
();
++
it
)
...
...
@@ -9456,7 +9457,7 @@ scan_number_done:
std
::
string
result
;
for
(
const
auto
c
:
token_string
)
{
if
(
'\x00'
<=
c
and
c
<=
'\x1F'
)
if
(
static_cast
<
unsigned
char
>
(
c
)
<=
'\x1F'
)
{
// escape control characters
std
::
array
<
char
,
9
>
cs
{{}};
...
...
@@ -18999,7 +19000,7 @@ class basic_json
not
std
::
is_same
<
ValueType
,
typename
string_t
::
value_type
>::
value
and
not
detail
::
is_basic_json
<
ValueType
>::
value
and
not
std
::
is_same
<
ValueType
,
std
::
initializer_list
<
typename
string_t
::
value_type
>>::
value
#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) and _MSC_VER <= 1914))
#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) and _MSC_VER
>= 1910 and _MSC_VER
<= 1914))
and
not
std
::
is_same
<
ValueType
,
typename
std
::
string_view
>::
value
#endif
and
detail
::
is_detected
<
detail
::
get_template_function
,
const
basic_json_t
&
,
ValueType
>::
value
...
...
test/CMakeLists.txt
View file @
32bda1a7
...
...
@@ -183,6 +183,7 @@ add_dependencies(json_unit download_test_data)
#############################################################################
# Test the generated build configs
#############################################################################
add_subdirectory
(
cmake_import
)
add_subdirectory
(
cmake_import_minver
)
add_subdirectory
(
cmake_add_subdirectory
)
...
...
test/src/unit-class_parser.cpp
View file @
32bda1a7
...
...
@@ -1489,6 +1489,18 @@ TEST_CASE("parser class")
[1,2,[3,4,5],4,5]
)"
;
auto
structured_array
=
R"(
[
1,
{
"foo": "bar"
},
{
"qux": "baz"
}
]
)"
;
SECTION
(
"filter nothing"
)
{
json
j_object
=
json
::
parse
(
s_object
,
[](
int
,
json
::
parse_event_t
,
const
json
&
)
...
...
@@ -1557,6 +1569,41 @@ TEST_CASE("parser class")
CHECK
(
j_array
==
json
({
1
,
{
3
,
4
,
5
},
4
,
5
}));
}
SECTION
(
"filter object in array"
)
{
json
j_filtered1
=
json
::
parse
(
structured_array
,
[](
int
,
json
::
parse_event_t
e
,
const
json
&
parsed
)
{
if
(
e
==
json
::
parse_event_t
::
object_end
and
parsed
.
contains
(
"foo"
))
{
return
false
;
}
else
{
return
true
;
}
});
// the specified object will be discarded, and removed.
CHECK
(
j_filtered1
.
size
()
==
2
);
CHECK
(
j_filtered1
==
json
({
1
,
{{
"qux"
,
"baz"
}}}));
json
j_filtered2
=
json
::
parse
(
structured_array
,
[](
int
,
json
::
parse_event_t
e
,
const
json
&
parsed
)
{
if
(
e
==
json
::
parse_event_t
::
object_end
)
{
return
false
;
}
else
{
return
true
;
}
});
// removed all objects in array.
CHECK
(
j_filtered2
.
size
()
==
1
);
CHECK
(
j_filtered2
==
json
({
1
}));
}
SECTION
(
"filter specific events"
)
{
SECTION
(
"first closing event"
)
...
...
test/src/unit-regression.cpp
View file @
32bda1a7
...
...
@@ -1890,6 +1890,28 @@ TEST_CASE("regression tests")
json
j
=
val
;
}
SECTION
(
"issue #1715 - json::from_cbor does not respect allow_exceptions = false when input is string literal"
)
{
SECTION
(
"string literal"
)
{
json
cbor
=
json
::
from_cbor
(
"B"
,
true
,
false
);
CHECK
(
cbor
.
is_discarded
());
}
SECTION
(
"string array"
)
{
const
char
input
[]
=
{
'B'
,
0x00
};
json
cbor
=
json
::
from_cbor
(
input
,
true
,
false
);
CHECK
(
cbor
.
is_discarded
());
}
SECTION
(
"std::string"
)
{
json
cbor
=
json
::
from_cbor
(
std
::
string
(
"B"
),
true
,
false
);
CHECK
(
cbor
.
is_discarded
());
}
}
SECTION
(
"issue #1805 - A pair<T1, T2> is json constructible only if T1 and T2 are json constructible"
)
{
static_assert
(
!
std
::
is_constructible
<
json
,
std
::
pair
<
std
::
string
,
NotSerializableData
>>::
value
,
""
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment