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
07494e06
Unverified
Commit
07494e06
authored
Aug 16, 2018
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🚨
fixed some compiler warnings
parent
d5b21b05
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
43 additions
and
43 deletions
+43
-43
include/nlohmann/detail/input/binary_reader.hpp
include/nlohmann/detail/input/binary_reader.hpp
+2
-2
include/nlohmann/detail/input/json_sax.hpp
include/nlohmann/detail/input/json_sax.hpp
+6
-6
include/nlohmann/detail/input/parser.hpp
include/nlohmann/detail/input/parser.hpp
+3
-3
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+11
-11
test/src/unit-conversions.cpp
test/src/unit-conversions.cpp
+1
-1
test/src/unit-deserialization.cpp
test/src/unit-deserialization.cpp
+18
-18
test/src/unit-inspection.cpp
test/src/unit-inspection.cpp
+2
-2
No files found.
include/nlohmann/detail/input/binary_reader.hpp
View file @
07494e06
...
@@ -1560,7 +1560,7 @@ class binary_reader
...
@@ -1560,7 +1560,7 @@ class binary_reader
}
}
else
else
{
{
if
(
JSON_UNLIKELY
(
not
sax
->
start_array
(
-
1
)))
if
(
JSON_UNLIKELY
(
not
sax
->
start_array
(
std
::
size_t
(
-
1
)
)))
{
{
return
false
;
return
false
;
}
}
...
@@ -1630,7 +1630,7 @@ class binary_reader
...
@@ -1630,7 +1630,7 @@ class binary_reader
}
}
else
else
{
{
if
(
JSON_UNLIKELY
(
not
sax
->
start_object
(
-
1
)))
if
(
JSON_UNLIKELY
(
not
sax
->
start_object
(
std
::
size_t
(
-
1
)
)))
{
{
return
false
;
return
false
;
}
}
...
...
include/nlohmann/detail/input/json_sax.hpp
View file @
07494e06
...
@@ -190,7 +190,7 @@ class json_sax_dom_parser
...
@@ -190,7 +190,7 @@ class json_sax_dom_parser
{
{
ref_stack
.
push_back
(
handle_value
(
BasicJsonType
::
value_t
::
object
));
ref_stack
.
push_back
(
handle_value
(
BasicJsonType
::
value_t
::
object
));
if
(
JSON_UNLIKELY
(
len
!=
-
1
and
len
>
ref_stack
.
back
()
->
max_size
()))
if
(
JSON_UNLIKELY
(
len
!=
std
::
size_t
(
-
1
)
and
len
>
ref_stack
.
back
()
->
max_size
()))
{
{
JSON_THROW
(
out_of_range
::
create
(
408
,
JSON_THROW
(
out_of_range
::
create
(
408
,
"excessive object size: "
+
std
::
to_string
(
len
)));
"excessive object size: "
+
std
::
to_string
(
len
)));
...
@@ -216,7 +216,7 @@ class json_sax_dom_parser
...
@@ -216,7 +216,7 @@ class json_sax_dom_parser
{
{
ref_stack
.
push_back
(
handle_value
(
BasicJsonType
::
value_t
::
array
));
ref_stack
.
push_back
(
handle_value
(
BasicJsonType
::
value_t
::
array
));
if
(
JSON_UNLIKELY
(
len
!=
-
1
and
len
>
ref_stack
.
back
()
->
max_size
()))
if
(
JSON_UNLIKELY
(
len
!=
std
::
size_t
(
-
1
)
and
len
>
ref_stack
.
back
()
->
max_size
()))
{
{
JSON_THROW
(
out_of_range
::
create
(
408
,
JSON_THROW
(
out_of_range
::
create
(
408
,
"excessive array size: "
+
std
::
to_string
(
len
)));
"excessive array size: "
+
std
::
to_string
(
len
)));
...
@@ -373,7 +373,7 @@ class json_sax_dom_callback_parser
...
@@ -373,7 +373,7 @@ class json_sax_dom_callback_parser
// check object limit
// check object limit
if
(
ref_stack
.
back
())
if
(
ref_stack
.
back
())
{
{
if
(
JSON_UNLIKELY
(
len
!=
-
1
and
len
>
ref_stack
.
back
()
->
max_size
()))
if
(
JSON_UNLIKELY
(
len
!=
std
::
size_t
(
-
1
)
and
len
>
ref_stack
.
back
()
->
max_size
()))
{
{
JSON_THROW
(
out_of_range
::
create
(
408
,
JSON_THROW
(
out_of_range
::
create
(
408
,
"excessive object size: "
+
std
::
to_string
(
len
)));
"excessive object size: "
+
std
::
to_string
(
len
)));
...
@@ -446,7 +446,7 @@ class json_sax_dom_callback_parser
...
@@ -446,7 +446,7 @@ class json_sax_dom_callback_parser
// check array limit
// check array limit
if
(
ref_stack
.
back
())
if
(
ref_stack
.
back
())
{
{
if
(
JSON_UNLIKELY
(
len
!=
-
1
and
len
>
ref_stack
.
back
()
->
max_size
()))
if
(
JSON_UNLIKELY
(
len
!=
std
::
size_t
(
-
1
)
and
len
>
ref_stack
.
back
()
->
max_size
()))
{
{
JSON_THROW
(
out_of_range
::
create
(
408
,
JSON_THROW
(
out_of_range
::
create
(
408
,
"excessive array size: "
+
std
::
to_string
(
len
)));
"excessive array size: "
+
std
::
to_string
(
len
)));
...
@@ -649,7 +649,7 @@ class json_sax_acceptor
...
@@ -649,7 +649,7 @@ class json_sax_acceptor
return
true
;
return
true
;
}
}
bool
start_object
(
std
::
size_t
=
-
1
)
bool
start_object
(
std
::
size_t
=
std
::
size_t
(
-
1
)
)
{
{
return
true
;
return
true
;
}
}
...
@@ -664,7 +664,7 @@ class json_sax_acceptor
...
@@ -664,7 +664,7 @@ class json_sax_acceptor
return
true
;
return
true
;
}
}
bool
start_array
(
std
::
size_t
=
-
1
)
bool
start_array
(
std
::
size_t
=
std
::
size_t
(
-
1
)
)
{
{
return
true
;
return
true
;
}
}
...
...
include/nlohmann/detail/input/parser.hpp
View file @
07494e06
...
@@ -146,7 +146,7 @@ class parser
...
@@ -146,7 +146,7 @@ class parser
template
<
typename
SAX
>
template
<
typename
SAX
>
bool
sax_parse
(
SAX
*
sax
,
const
bool
strict
=
true
)
bool
sax_parse
(
SAX
*
sax
,
const
bool
strict
=
true
)
{
{
(
void
)
detail
::
is_sax_static_asserts
<
SAX
,
BasicJsonType
>
{};
(
void
)
detail
::
is_sax_static_asserts
<
SAX
,
BasicJsonType
>
{};
const
bool
result
=
sax_parse_internal
(
sax
);
const
bool
result
=
sax_parse_internal
(
sax
);
// strict mode: next byte must be EOF
// strict mode: next byte must be EOF
...
@@ -179,7 +179,7 @@ class parser
...
@@ -179,7 +179,7 @@ class parser
{
{
case
token_type
:
:
begin_object
:
case
token_type
:
:
begin_object
:
{
{
if
(
JSON_UNLIKELY
(
not
sax
->
start_object
(
-
1
)))
if
(
JSON_UNLIKELY
(
not
sax
->
start_object
(
std
::
size_t
(
-
1
)
)))
{
{
return
false
;
return
false
;
}
}
...
@@ -227,7 +227,7 @@ class parser
...
@@ -227,7 +227,7 @@ class parser
case
token_type
:
:
begin_array
:
case
token_type
:
:
begin_array
:
{
{
if
(
JSON_UNLIKELY
(
not
sax
->
start_array
(
-
1
)))
if
(
JSON_UNLIKELY
(
not
sax
->
start_array
(
std
::
size_t
(
-
1
)
)))
{
{
return
false
;
return
false
;
}
}
...
...
single_include/nlohmann/json.hpp
View file @
07494e06
...
@@ -3966,7 +3966,7 @@ class json_sax_dom_parser
...
@@ -3966,7 +3966,7 @@ class json_sax_dom_parser
{
{
ref_stack
.
push_back
(
handle_value
(
BasicJsonType
::
value_t
::
object
));
ref_stack
.
push_back
(
handle_value
(
BasicJsonType
::
value_t
::
object
));
if
(
JSON_UNLIKELY
(
len
!=
-
1
and
len
>
ref_stack
.
back
()
->
max_size
()))
if
(
JSON_UNLIKELY
(
len
!=
std
::
size_t
(
-
1
)
and
len
>
ref_stack
.
back
()
->
max_size
()))
{
{
JSON_THROW
(
out_of_range
::
create
(
408
,
JSON_THROW
(
out_of_range
::
create
(
408
,
"excessive object size: "
+
std
::
to_string
(
len
)));
"excessive object size: "
+
std
::
to_string
(
len
)));
...
@@ -3992,7 +3992,7 @@ class json_sax_dom_parser
...
@@ -3992,7 +3992,7 @@ class json_sax_dom_parser
{
{
ref_stack
.
push_back
(
handle_value
(
BasicJsonType
::
value_t
::
array
));
ref_stack
.
push_back
(
handle_value
(
BasicJsonType
::
value_t
::
array
));
if
(
JSON_UNLIKELY
(
len
!=
-
1
and
len
>
ref_stack
.
back
()
->
max_size
()))
if
(
JSON_UNLIKELY
(
len
!=
std
::
size_t
(
-
1
)
and
len
>
ref_stack
.
back
()
->
max_size
()))
{
{
JSON_THROW
(
out_of_range
::
create
(
408
,
JSON_THROW
(
out_of_range
::
create
(
408
,
"excessive array size: "
+
std
::
to_string
(
len
)));
"excessive array size: "
+
std
::
to_string
(
len
)));
...
@@ -4149,7 +4149,7 @@ class json_sax_dom_callback_parser
...
@@ -4149,7 +4149,7 @@ class json_sax_dom_callback_parser
// check object limit
// check object limit
if
(
ref_stack
.
back
())
if
(
ref_stack
.
back
())
{
{
if
(
JSON_UNLIKELY
(
len
!=
-
1
and
len
>
ref_stack
.
back
()
->
max_size
()))
if
(
JSON_UNLIKELY
(
len
!=
std
::
size_t
(
-
1
)
and
len
>
ref_stack
.
back
()
->
max_size
()))
{
{
JSON_THROW
(
out_of_range
::
create
(
408
,
JSON_THROW
(
out_of_range
::
create
(
408
,
"excessive object size: "
+
std
::
to_string
(
len
)));
"excessive object size: "
+
std
::
to_string
(
len
)));
...
@@ -4222,7 +4222,7 @@ class json_sax_dom_callback_parser
...
@@ -4222,7 +4222,7 @@ class json_sax_dom_callback_parser
// check array limit
// check array limit
if
(
ref_stack
.
back
())
if
(
ref_stack
.
back
())
{
{
if
(
JSON_UNLIKELY
(
len
!=
-
1
and
len
>
ref_stack
.
back
()
->
max_size
()))
if
(
JSON_UNLIKELY
(
len
!=
std
::
size_t
(
-
1
)
and
len
>
ref_stack
.
back
()
->
max_size
()))
{
{
JSON_THROW
(
out_of_range
::
create
(
408
,
JSON_THROW
(
out_of_range
::
create
(
408
,
"excessive array size: "
+
std
::
to_string
(
len
)));
"excessive array size: "
+
std
::
to_string
(
len
)));
...
@@ -4425,7 +4425,7 @@ class json_sax_acceptor
...
@@ -4425,7 +4425,7 @@ class json_sax_acceptor
return
true
;
return
true
;
}
}
bool
start_object
(
std
::
size_t
=
-
1
)
bool
start_object
(
std
::
size_t
=
std
::
size_t
(
-
1
)
)
{
{
return
true
;
return
true
;
}
}
...
@@ -4440,7 +4440,7 @@ class json_sax_acceptor
...
@@ -4440,7 +4440,7 @@ class json_sax_acceptor
return
true
;
return
true
;
}
}
bool
start_array
(
std
::
size_t
=
-
1
)
bool
start_array
(
std
::
size_t
=
std
::
size_t
(
-
1
)
)
{
{
return
true
;
return
true
;
}
}
...
@@ -4595,7 +4595,7 @@ class parser
...
@@ -4595,7 +4595,7 @@ class parser
template
<
typename
SAX
>
template
<
typename
SAX
>
bool
sax_parse
(
SAX
*
sax
,
const
bool
strict
=
true
)
bool
sax_parse
(
SAX
*
sax
,
const
bool
strict
=
true
)
{
{
// (void)detail::is_sax_static_asserts<SAX, BasicJsonType>
{};
(
void
)
detail
::
is_sax_static_asserts
<
SAX
,
BasicJsonType
>
{};
const
bool
result
=
sax_parse_internal
(
sax
);
const
bool
result
=
sax_parse_internal
(
sax
);
// strict mode: next byte must be EOF
// strict mode: next byte must be EOF
...
@@ -4628,7 +4628,7 @@ class parser
...
@@ -4628,7 +4628,7 @@ class parser
{
{
case
token_type
:
:
begin_object
:
case
token_type
:
:
begin_object
:
{
{
if
(
JSON_UNLIKELY
(
not
sax
->
start_object
(
-
1
)))
if
(
JSON_UNLIKELY
(
not
sax
->
start_object
(
std
::
size_t
(
-
1
)
)))
{
{
return
false
;
return
false
;
}
}
...
@@ -4676,7 +4676,7 @@ class parser
...
@@ -4676,7 +4676,7 @@ class parser
case
token_type
:
:
begin_array
:
case
token_type
:
:
begin_array
:
{
{
if
(
JSON_UNLIKELY
(
not
sax
->
start_array
(
-
1
)))
if
(
JSON_UNLIKELY
(
not
sax
->
start_array
(
std
::
size_t
(
-
1
)
)))
{
{
return
false
;
return
false
;
}
}
...
@@ -7515,7 +7515,7 @@ class binary_reader
...
@@ -7515,7 +7515,7 @@ class binary_reader
}
}
else
else
{
{
if
(
JSON_UNLIKELY
(
not
sax
->
start_array
(
-
1
)))
if
(
JSON_UNLIKELY
(
not
sax
->
start_array
(
std
::
size_t
(
-
1
)
)))
{
{
return
false
;
return
false
;
}
}
...
@@ -7585,7 +7585,7 @@ class binary_reader
...
@@ -7585,7 +7585,7 @@ class binary_reader
}
}
else
else
{
{
if
(
JSON_UNLIKELY
(
not
sax
->
start_object
(
-
1
)))
if
(
JSON_UNLIKELY
(
not
sax
->
start_object
(
std
::
size_t
(
-
1
)
)))
{
{
return
false
;
return
false
;
}
}
...
...
test/src/unit-conversions.cpp
View file @
07494e06
...
@@ -435,7 +435,7 @@ TEST_CASE("value conversion")
...
@@ -435,7 +435,7 @@ TEST_CASE("value conversion")
SECTION
(
"get null (explicit)"
)
SECTION
(
"get null (explicit)"
)
{
{
std
::
nullptr_t
n
;
std
::
nullptr_t
n
=
nullptr
;
json
j
(
n
);
json
j
(
n
);
auto
n2
=
j
.
get
<
std
::
nullptr_t
>
();
auto
n2
=
j
.
get
<
std
::
nullptr_t
>
();
...
...
test/src/unit-deserialization.cpp
View file @
07494e06
...
@@ -35,45 +35,45 @@ using nlohmann::json;
...
@@ -35,45 +35,45 @@ using nlohmann::json;
#include <iostream>
#include <iostream>
#include <valarray>
#include <valarray>
struct
SaxEventLogger
struct
SaxEventLogger
:
public
nlohmann
::
json_sax
<
json
>
{
{
bool
null
()
bool
null
()
override
{
{
events
.
push_back
(
"null()"
);
events
.
push_back
(
"null()"
);
return
true
;
return
true
;
}
}
bool
boolean
(
bool
val
)
bool
boolean
(
bool
val
)
override
{
{
events
.
push_back
(
val
?
"boolean(true)"
:
"boolean(false)"
);
events
.
push_back
(
val
?
"boolean(true)"
:
"boolean(false)"
);
return
true
;
return
true
;
}
}
bool
number_integer
(
json
::
number_integer_t
val
)
bool
number_integer
(
json
::
number_integer_t
val
)
override
{
{
events
.
push_back
(
"number_integer("
+
std
::
to_string
(
val
)
+
")"
);
events
.
push_back
(
"number_integer("
+
std
::
to_string
(
val
)
+
")"
);
return
true
;
return
true
;
}
}
bool
number_unsigned
(
json
::
number_unsigned_t
val
)
bool
number_unsigned
(
json
::
number_unsigned_t
val
)
override
{
{
events
.
push_back
(
"number_unsigned("
+
std
::
to_string
(
val
)
+
")"
);
events
.
push_back
(
"number_unsigned("
+
std
::
to_string
(
val
)
+
")"
);
return
true
;
return
true
;
}
}
bool
number_float
(
json
::
number_float_t
,
const
std
::
string
&
s
)
bool
number_float
(
json
::
number_float_t
,
const
std
::
string
&
s
)
override
{
{
events
.
push_back
(
"number_float("
+
s
+
")"
);
events
.
push_back
(
"number_float("
+
s
+
")"
);
return
true
;
return
true
;
}
}
bool
string
(
std
::
string
&
val
)
bool
string
(
std
::
string
&
val
)
override
{
{
events
.
push_back
(
"string("
+
val
+
")"
);
events
.
push_back
(
"string("
+
val
+
")"
);
return
true
;
return
true
;
}
}
bool
start_object
(
std
::
size_t
elements
)
bool
start_object
(
std
::
size_t
elements
)
override
{
{
if
(
elements
==
std
::
size_t
(
-
1
))
if
(
elements
==
std
::
size_t
(
-
1
))
{
{
...
@@ -86,19 +86,19 @@ struct SaxEventLogger
...
@@ -86,19 +86,19 @@ struct SaxEventLogger
return
true
;
return
true
;
}
}
bool
key
(
std
::
string
&
val
)
bool
key
(
std
::
string
&
val
)
override
{
{
events
.
push_back
(
"key("
+
val
+
")"
);
events
.
push_back
(
"key("
+
val
+
")"
);
return
true
;
return
true
;
}
}
bool
end_object
()
bool
end_object
()
override
{
{
events
.
push_back
(
"end_object()"
);
events
.
push_back
(
"end_object()"
);
return
true
;
return
true
;
}
}
bool
start_array
(
std
::
size_t
elements
)
bool
start_array
(
std
::
size_t
elements
)
override
{
{
if
(
elements
==
std
::
size_t
(
-
1
))
if
(
elements
==
std
::
size_t
(
-
1
))
{
{
...
@@ -111,13 +111,13 @@ struct SaxEventLogger
...
@@ -111,13 +111,13 @@ struct SaxEventLogger
return
true
;
return
true
;
}
}
bool
end_array
()
bool
end_array
()
override
{
{
events
.
push_back
(
"end_array()"
);
events
.
push_back
(
"end_array()"
);
return
true
;
return
true
;
}
}
bool
parse_error
(
std
::
size_t
position
,
const
std
::
string
&
,
const
json
::
exception
&
)
bool
parse_error
(
std
::
size_t
position
,
const
std
::
string
&
,
const
json
::
exception
&
)
override
{
{
events
.
push_back
(
"parse_error("
+
std
::
to_string
(
position
)
+
")"
);
events
.
push_back
(
"parse_error("
+
std
::
to_string
(
position
)
+
")"
);
return
false
;
return
false
;
...
@@ -128,9 +128,9 @@ struct SaxEventLogger
...
@@ -128,9 +128,9 @@ struct SaxEventLogger
struct
SaxEventLoggerExitAfterStartObject
:
public
SaxEventLogger
struct
SaxEventLoggerExitAfterStartObject
:
public
SaxEventLogger
{
{
bool
start_object
(
std
::
size_t
elements
)
bool
start_object
(
std
::
size_t
elements
)
override
{
{
if
(
elements
==
-
1
)
if
(
elements
==
std
::
size_t
(
-
1
)
)
{
{
events
.
push_back
(
"start_object()"
);
events
.
push_back
(
"start_object()"
);
}
}
...
@@ -144,7 +144,7 @@ struct SaxEventLoggerExitAfterStartObject : public SaxEventLogger
...
@@ -144,7 +144,7 @@ struct SaxEventLoggerExitAfterStartObject : public SaxEventLogger
struct
SaxEventLoggerExitAfterKey
:
public
SaxEventLogger
struct
SaxEventLoggerExitAfterKey
:
public
SaxEventLogger
{
{
bool
key
(
std
::
string
&
val
)
bool
key
(
std
::
string
&
val
)
override
{
{
events
.
push_back
(
"key("
+
val
+
")"
);
events
.
push_back
(
"key("
+
val
+
")"
);
return
false
;
return
false
;
...
@@ -153,9 +153,9 @@ struct SaxEventLoggerExitAfterKey : public SaxEventLogger
...
@@ -153,9 +153,9 @@ struct SaxEventLoggerExitAfterKey : public SaxEventLogger
struct
SaxEventLoggerExitAfterStartArray
:
public
SaxEventLogger
struct
SaxEventLoggerExitAfterStartArray
:
public
SaxEventLogger
{
{
bool
start_array
(
std
::
size_t
elements
)
bool
start_array
(
std
::
size_t
elements
)
override
{
{
if
(
elements
==
-
1
)
if
(
elements
==
std
::
size_t
(
-
1
)
)
{
{
events
.
push_back
(
"start_array()"
);
events
.
push_back
(
"start_array()"
);
}
}
...
...
test/src/unit-inspection.cpp
View file @
07494e06
...
@@ -317,8 +317,8 @@ TEST_CASE("object inspection")
...
@@ -317,8 +317,8 @@ TEST_CASE("object inspection")
SECTION
(
"round trips"
)
SECTION
(
"round trips"
)
{
{
for
(
const
auto
&
s
:
for
(
const
auto
&
s
:
{
"3.141592653589793"
,
"1000000000000000010E5"
{
"3.141592653589793"
,
"1000000000000000010E5"
})
})
{
{
json
j1
=
json
::
parse
(
s
);
json
j1
=
json
::
parse
(
s
);
std
::
string
s1
=
j1
.
dump
();
std
::
string
s1
=
j1
.
dump
();
...
...
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