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
3811daa8
Unverified
Commit
3811daa8
authored
Aug 18, 2018
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
📝
release preparation
parent
6899fa30
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
175 additions
and
37 deletions
+175
-37
Makefile
Makefile
+1
-1
README.md
README.md
+10
-0
include/nlohmann/detail/input/binary_reader.hpp
include/nlohmann/detail/input/binary_reader.hpp
+3
-1
include/nlohmann/detail/input/json_sax.hpp
include/nlohmann/detail/input/json_sax.hpp
+16
-12
include/nlohmann/detail/input/lexer.hpp
include/nlohmann/detail/input/lexer.hpp
+6
-2
include/nlohmann/json.hpp
include/nlohmann/json.hpp
+57
-3
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+82
-18
No files found.
Makefile
View file @
3811daa8
...
...
@@ -86,7 +86,7 @@ clean:
coverage
:
mkdir
build_coverage
cd
build_coverage
;
CXX
=
g++-
5
cmake ..
-GNinja
-DJSON_Coverage
=
ON
-DJSON_MultipleHeaders
=
ON
cd
build_coverage
;
CXX
=
g++-
7
cmake ..
-GNinja
-DJSON_Coverage
=
ON
-DJSON_MultipleHeaders
=
ON
cd
build_coverage
;
ninja
cd
build_coverage
;
ctest
-E
'.*_default'
-j10
cd
build_coverage
;
ninja lcov_html
...
...
README.md
View file @
3811daa8
...
...
@@ -1046,6 +1046,16 @@ I deeply appreciate the help of the following people.
-
[
Carlos O'Ryan
](
https://github.com/coryan
)
fixed a typo.
-
[
James Upjohn
](
https://github.com/jammehcow
)
fixed a version number in the compilers section.
-
[
Chuck Atkins
](
https://github.com/chuckatkins
)
adjusted the CMake files to the CMake packaging guidelines
-
[
Jan Schöppach
](
https://github.com/dns13
)
fixed a typo.
-
[
martin-mfg
](
https://github.com/martin-mfg
)
fixed a typo.
-
[
Matthias Möller
](
https://github.com/TinyTinni
)
removed the dependency from
`std::stringstream`
.
-
[
agrianius
](
https://github.com/agrianius
)
added code to use alternative string implementations.
-
[
Daniel599
](
https://github.com/Daniel599
)
allowed to use more algorithms with the
`items()`
function.
-
[
Julius Rakow
](
https://github.com/jrakow
)
fixed the Meson include directory and fixed the links to
[
cppreference.com
](
cppreference.com
)
.
-
[
Sonu Lohani
](
https://github.com/sonulohani
)
fixed the compilation with MSVC 2015 in debug mode.
-
[
grembo
](
https://github.com/grembo
)
fixed the test suite and re-enabled several test cases.
-
[
Hyeon Kim
](
https://github.com/simnalamburt
)
introduced the macro
`JSON_INTERNAL_CATCH`
to control the exception handling inside the library.
-
[
thyu
](
https://github.com/thyu
)
fixed a compiler warning.
Thanks a lot for helping out! Please
[
let me know
](
mailto:mail@nlohmann.me
)
if I forgot someone.
...
...
include/nlohmann/detail/input/binary_reader.hpp
View file @
3811daa8
...
...
@@ -80,8 +80,10 @@ class binary_reader
result
=
parse_ubjson_internal
();
break
;
// LCOV_EXCL_START
default:
assert
(
false
);
// LCOV_EXCL_LINE
assert
(
false
);
// LCOV_EXCL_STOP
}
// strict mode: next byte must be EOF
...
...
include/nlohmann/detail/input/json_sax.hpp
View file @
3811daa8
...
...
@@ -249,16 +249,18 @@ class json_sax_dom_parser
{
case
1
:
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
parse_error
*>
(
&
ex
));
case
2
:
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
invalid_iterator
*>
(
&
ex
));
// LCOV_EXCL_LINE
case
3
:
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
type_error
*>
(
&
ex
));
// LCOV_EXCL_LINE
case
4
:
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
out_of_range
*>
(
&
ex
));
// LCOV_EXCL_START
case
2
:
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
invalid_iterator
*>
(
&
ex
));
case
3
:
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
type_error
*>
(
&
ex
));
case
5
:
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
other_error
*>
(
&
ex
));
// LCOV_EXCL_LINE
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
other_error
*>
(
&
ex
));
default:
assert
(
false
);
// LCOV_EXCL_LINE
assert
(
false
);
// LCOV_EXCL_STOP
}
}
return
false
;
...
...
@@ -505,16 +507,18 @@ class json_sax_dom_callback_parser
{
case
1
:
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
parse_error
*>
(
&
ex
));
case
2
:
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
invalid_iterator
*>
(
&
ex
));
// LCOV_EXCL_LINE
case
3
:
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
type_error
*>
(
&
ex
));
// LCOV_EXCL_LINE
case
4
:
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
out_of_range
*>
(
&
ex
));
// LCOV_EXCL_START
case
2
:
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
invalid_iterator
*>
(
&
ex
));
case
3
:
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
type_error
*>
(
&
ex
));
case
5
:
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
other_error
*>
(
&
ex
));
// LCOV_EXCL_LINE
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
other_error
*>
(
&
ex
));
default:
assert
(
false
);
// LCOV_EXCL_LINE
assert
(
false
);
// LCOV_EXCL_STOP
}
}
return
false
;
...
...
include/nlohmann/detail/input/lexer.hpp
View file @
3811daa8
...
...
@@ -92,8 +92,10 @@ class lexer
return
"end of input"
;
case
token_type
:
:
literal_or_value
:
return
"'[', '{', or a literal"
;
// LCOV_EXCL_START
default:
// catch non-enum values
return
"unknown token"
;
// LCOV_EXCL_LINE
return
"unknown token"
;
// LCOV_EXCL_STOP
}
}
...
...
@@ -745,11 +747,13 @@ class lexer
goto
scan_number_any1
;
}
// LCOV_EXCL_START
default:
{
// all other characters are rejected outside scan_number()
assert
(
false
);
// LCOV_EXCL_LINE
assert
(
false
);
}
// LCOV_EXCL_STOP
}
scan_number_minus:
...
...
include/nlohmann/json.hpp
View file @
3811daa8
...
...
@@ -1276,7 +1276,7 @@ class basic_json
was provided), strong guarantee holds: if an exception is thrown, there are
no changes to any JSON value.
@since version 3.
1.2
@since version 3.
2.0
*/
template
<
typename
BasicJsonType
,
detail
::
enable_if_t
<
...
...
@@ -2509,7 +2509,7 @@ class basic_json
@complexity Depending on the implementation of the called `from_json()`
method.
@since version 3.
1.2
@since version 3.
2.0
*/
template
<
typename
BasicJsonType
,
detail
::
enable_if_t
<
not
std
::
is_same
<
BasicJsonType
,
basic_json
>
::
value
and
...
...
@@ -6014,6 +6014,58 @@ class basic_json
return
parser
(
i
).
accept
(
true
);
}
/*!
@brief generate SAX events
The SAX event lister must follow the interface of @ref json_sax.
This function reads from a compatible input. Examples are:
- an array of 1-byte values
- strings with character/literal type with size of 1 byte
- input streams
- container with contiguous storage of 1-byte values. Compatible container
types include `std::vector`, `std::string`, `std::array`,
`std::valarray`, and `std::initializer_list`. Furthermore, C-style
arrays can be used with `std::begin()`/`std::end()`. User-defined
containers can be used as long as they implement random-access iterators
and a contiguous storage.
@pre Each element of the container has a size of 1 byte. Violating this
precondition yields undefined behavior. **This precondition is enforced
with a static assertion.**
@pre The container storage is contiguous. Violating this precondition
yields undefined behavior. **This precondition is enforced with an
assertion.**
@pre Each element of the container has a size of 1 byte. Violating this
precondition yields undefined behavior. **This precondition is enforced
with a static assertion.**
@warning There is no way to enforce all preconditions at compile-time. If
the function is called with a noncompliant container and with
assertions switched off, the behavior is undefined and will most
likely yield segmentation violation.
@param[in] i input to read from
@param[in,out] sax SAX event listener
@param[in] format the format to parse (JSON, CBOR, MessagePack, or UBJSON)
@param[in] strict whether the input has to be consumed completely
@return return value of the last processed SAX event
@throw parse_error.101 if a parse error occurs; example: `""unexpected end
of input; expected string literal""`
@throw parse_error.102 if to_unicode fails or surrogate error
@throw parse_error.103 if to_unicode fails
@complexity Linear in the length of the input. The parser is a predictive
LL(1) parser. The complexity can be higher if the SAX consumer @a sax has
a super-linear complexity.
@note A UTF-8 byte order mark is silently ignored.
@since version 3.2.0
*/
template
<
typename
SAX
>
static
bool
sax_parse
(
detail
::
input_adapter
&&
i
,
SAX
*
sax
,
input_format_t
format
=
input_format_t
::
json
,
...
...
@@ -7215,11 +7267,13 @@ class basic_json
break
;
}
// LCOV_EXCL_START
default:
{
// if there exists a parent it cannot be primitive
assert
(
false
);
// LCOV_EXCL_LINE
assert
(
false
);
}
// LCOV_EXCL_STOP
}
}
};
...
...
single_include/nlohmann/json.hpp
View file @
3811daa8
...
...
@@ -2307,8 +2307,10 @@ class lexer
return
"end of input"
;
case
token_type
:
:
literal_or_value
:
return
"'[', '{', or a literal"
;
// LCOV_EXCL_START
default:
// catch non-enum values
return "unknown token"; // LCOV_EXCL_LINE
return
"unknown token"
;
// LCOV_EXCL_STOP
}
}
...
...
@@ -2960,11 +2962,13 @@ class lexer
goto
scan_number_any1
;
}
// LCOV_EXCL_START
default:
{
// all other characters are rejected outside scan_number()
assert(false);
// LCOV_EXCL_LINE
assert
(
false
);
}
// LCOV_EXCL_STOP
}
scan_number_minus:
...
...
@@ -4025,16 +4029,18 @@ class json_sax_dom_parser
{
case
1
:
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
parse_error
*>
(
&
ex
));
case 2:
JSON_THROW(*reinterpret_cast<const detail::invalid_iterator*>(&ex)); // LCOV_EXCL_LINE
case 3:
JSON_THROW(*reinterpret_cast<const detail::type_error*>(&ex)); // LCOV_EXCL_LINE
case
4
:
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
out_of_range
*>
(
&
ex
));
// LCOV_EXCL_START
case
2
:
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
invalid_iterator
*>
(
&
ex
));
case
3
:
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
type_error
*>
(
&
ex
));
case
5
:
JSON_THROW(*reinterpret_cast<const detail::other_error*>(&ex));
// LCOV_EXCL_LINE
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
other_error
*>
(
&
ex
));
default:
assert(false); // LCOV_EXCL_LINE
assert
(
false
);
// LCOV_EXCL_STOP
}
}
return
false
;
...
...
@@ -4281,16 +4287,18 @@ class json_sax_dom_callback_parser
{
case
1
:
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
parse_error
*>
(
&
ex
));
case 2:
JSON_THROW(*reinterpret_cast<const detail::invalid_iterator*>(&ex)); // LCOV_EXCL_LINE
case 3:
JSON_THROW(*reinterpret_cast<const detail::type_error*>(&ex)); // LCOV_EXCL_LINE
case
4
:
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
out_of_range
*>
(
&
ex
));
// LCOV_EXCL_START
case
2
:
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
invalid_iterator
*>
(
&
ex
));
case
3
:
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
type_error
*>
(
&
ex
));
case
5
:
JSON_THROW(*reinterpret_cast<const detail::other_error*>(&ex));
// LCOV_EXCL_LINE
JSON_THROW
(
*
reinterpret_cast
<
const
detail
::
other_error
*>
(
&
ex
));
default:
assert(false); // LCOV_EXCL_LINE
assert
(
false
);
// LCOV_EXCL_STOP
}
}
return
false
;
...
...
@@ -6049,8 +6057,10 @@ class binary_reader
result
=
parse_ubjson_internal
();
break
;
// LCOV_EXCL_START
default:
assert(false); // LCOV_EXCL_LINE
assert
(
false
);
// LCOV_EXCL_STOP
}
// strict mode: next byte must be EOF
...
...
@@ -12372,7 +12382,7 @@ class basic_json
was provided), strong guarantee holds: if an exception is thrown, there are
no changes to any JSON value.
@since version 3.
1.2
@since version 3.
2.0
*/
template
<
typename
BasicJsonType
,
detail
::
enable_if_t
<
...
...
@@ -13605,7 +13615,7 @@ class basic_json
@complexity Depending on the implementation of the called `from_json()`
method.
@since version 3.
1.2
@since version 3.
2.0
*/
template
<
typename
BasicJsonType
,
detail
::
enable_if_t
<
not
std
::
is_same
<
BasicJsonType
,
basic_json
>
::
value
and
...
...
@@ -17110,6 +17120,58 @@ class basic_json
return
parser
(
i
).
accept
(
true
);
}
/*!
@brief generate SAX events
The SAX event lister must follow the interface of @ref json_sax.
This function reads from a compatible input. Examples are:
- an array of 1-byte values
- strings with character/literal type with size of 1 byte
- input streams
- container with contiguous storage of 1-byte values. Compatible container
types include `std::vector`, `std::string`, `std::array`,
`std::valarray`, and `std::initializer_list`. Furthermore, C-style
arrays can be used with `std::begin()`/`std::end()`. User-defined
containers can be used as long as they implement random-access iterators
and a contiguous storage.
@pre Each element of the container has a size of 1 byte. Violating this
precondition yields undefined behavior. **This precondition is enforced
with a static assertion.**
@pre The container storage is contiguous. Violating this precondition
yields undefined behavior. **This precondition is enforced with an
assertion.**
@pre Each element of the container has a size of 1 byte. Violating this
precondition yields undefined behavior. **This precondition is enforced
with a static assertion.**
@warning There is no way to enforce all preconditions at compile-time. If
the function is called with a noncompliant container and with
assertions switched off, the behavior is undefined and will most
likely yield segmentation violation.
@param[in] i input to read from
@param[in,out] sax SAX event listener
@param[in] format the format to parse (JSON, CBOR, MessagePack, or UBJSON)
@param[in] strict whether the input has to be consumed completely
@return result of the deserialization
@throw parse_error.101 if a parse error occurs; example: `""unexpected end
of input; expected string literal""`
@throw parse_error.102 if to_unicode fails or surrogate error
@throw parse_error.103 if to_unicode fails
@complexity Linear in the length of the input. The parser is a predictive
LL(1) parser. The complexity can be higher if the SAX consumer @a sax has
a super-linear complexity.
@note A UTF-8 byte order mark is silently ignored.
@since version 3.2.0
*/
template
<
typename
SAX
>
static
bool
sax_parse
(
detail
::
input_adapter
&&
i
,
SAX
*
sax
,
input_format_t
format
=
input_format_t
::
json
,
...
...
@@ -18311,11 +18373,13 @@ class basic_json
break
;
}
// LCOV_EXCL_START
default:
{
// if there exists a parent it cannot be primitive
assert(false);
// LCOV_EXCL_LINE
assert
(
false
);
}
// LCOV_EXCL_STOP
}
}
};
...
...
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