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
b4571360
Commit
b4571360
authored
Aug 21, 2016
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more on #290
parent
eef80590
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
299 additions
and
102 deletions
+299
-102
README.md
README.md
+1
-1
doc/examples/parse__array__parser_callback_t.cpp
doc/examples/parse__array__parser_callback_t.cpp
+28
-0
doc/examples/parse__array__parser_callback_t.link
doc/examples/parse__array__parser_callback_t.link
+1
-0
doc/examples/parse__array__parser_callback_t.output
doc/examples/parse__array__parser_callback_t.output
+20
-0
doc/examples/parse__contiguouscontainer__parser_callback_t.cpp
...xamples/parse__contiguouscontainer__parser_callback_t.cpp
+13
-0
doc/examples/parse__contiguouscontainer__parser_callback_t.link
...amples/parse__contiguouscontainer__parser_callback_t.link
+1
-0
doc/examples/parse__contiguouscontainer__parser_callback_t.output
...ples/parse__contiguouscontainer__parser_callback_t.output
+6
-0
doc/examples/parse__iteratortype__parser_callback_t.cpp
doc/examples/parse__iteratortype__parser_callback_t.cpp
+13
-0
doc/examples/parse__iteratortype__parser_callback_t.link
doc/examples/parse__iteratortype__parser_callback_t.link
+1
-0
doc/examples/parse__iteratortype__parser_callback_t.output
doc/examples/parse__iteratortype__parser_callback_t.output
+6
-0
doc/examples/parse__string__parser_callback_t.cpp
doc/examples/parse__string__parser_callback_t.cpp
+2
-2
doc/examples/parse__string__parser_callback_t.link
doc/examples/parse__string__parser_callback_t.link
+1
-1
src/json.hpp
src/json.hpp
+92
-41
src/json.hpp.re2c
src/json.hpp.re2c
+92
-41
test/src/unit-class_parser.cpp
test/src/unit-class_parser.cpp
+16
-16
test/src/unit-deserialization.cpp
test/src/unit-deserialization.cpp
+6
-0
No files found.
README.md
View file @
b4571360
...
...
@@ -511,7 +511,7 @@ To compile and run the tests, you need to execute
$
make check
===============================================================================
All tests passed
(
8905
09
9 assertions
in
32
test
cases
)
All tests passed
(
8905
11
9 assertions
in
32
test
cases
)
```
For more information, have a look at the file
[
.travis.yml
](
https://github.com/nlohmann/json/blob/master/.travis.yml
)
.
doc/examples/parse__array__parser_callback_t.cpp
0 → 100644
View file @
b4571360
#include <json.hpp>
using
json
=
nlohmann
::
json
;
int
main
()
{
// a JSON text
char
text
[]
=
R"(
{
"Image": {
"Width": 800,
"Height": 600,
"Title": "View from 15th Floor",
"Thumbnail": {
"Url": "http://www.example.com/image/481989943",
"Height": 125,
"Width": 100
},
"Animated" : false,
"IDs": [116, 943, 234, 38793]
}
}
)"
;
// parse and serialize JSON
json
j_complete
=
json
::
parse
(
text
);
std
::
cout
<<
std
::
setw
(
4
)
<<
j_complete
<<
"
\n\n
"
;
}
doc/examples/parse__array__parser_callback_t.link
0 → 100644
View file @
b4571360
<a target="_blank" href="http://melpon.org/wandbox/permlink/LvZQq5fybVH1nh9L"><b>online</b></a>
\ No newline at end of file
doc/examples/parse__array__parser_callback_t.output
0 → 100644
View file @
b4571360
{
"Image": {
"Animated": false,
"Height": 600,
"IDs": [
116,
943,
234,
38793
],
"Thumbnail": {
"Height": 125,
"Url": "http://www.example.com/image/481989943",
"Width": 100
},
"Title": "View from 15th Floor",
"Width": 800
}
}
doc/examples/parse__contiguouscontainer__parser_callback_t.cpp
0 → 100644
View file @
b4571360
#include <json.hpp>
using
json
=
nlohmann
::
json
;
int
main
()
{
// a JSON text given as std::vector
std
::
vector
<
uint8_t
>
text
=
{
'['
,
'1'
,
','
,
'2'
,
','
,
'3'
,
']'
,
'\0'
};
// parse and serialize JSON
json
j_complete
=
json
::
parse
(
text
);
std
::
cout
<<
std
::
setw
(
4
)
<<
j_complete
<<
"
\n\n
"
;
}
doc/examples/parse__contiguouscontainer__parser_callback_t.link
0 → 100644
View file @
b4571360
<a target="_blank" href="http://melpon.org/wandbox/permlink/F8VaVFyys87qQRt5"><b>online</b></a>
\ No newline at end of file
doc/examples/parse__contiguouscontainer__parser_callback_t.output
0 → 100644
View file @
b4571360
[
1,
2,
3
]
doc/examples/parse__iteratortype__parser_callback_t.cpp
0 → 100644
View file @
b4571360
#include <json.hpp>
using
json
=
nlohmann
::
json
;
int
main
()
{
// a JSON text given as std::vector
std
::
vector
<
uint8_t
>
text
=
{
'['
,
'1'
,
','
,
'2'
,
','
,
'3'
,
']'
,
'\0'
};
// parse and serialize JSON
json
j_complete
=
json
::
parse
(
text
.
begin
(),
text
.
end
());
std
::
cout
<<
std
::
setw
(
4
)
<<
j_complete
<<
"
\n\n
"
;
}
doc/examples/parse__iteratortype__parser_callback_t.link
0 → 100644
View file @
b4571360
<a target="_blank" href="http://melpon.org/wandbox/permlink/ojh4Eeol4G9RgeRV"><b>online</b></a>
\ No newline at end of file
doc/examples/parse__iteratortype__parser_callback_t.output
0 → 100644
View file @
b4571360
[
1,
2,
3
]
doc/examples/parse__string__parser_callback_t.cpp
View file @
b4571360
...
...
@@ -5,7 +5,7 @@ using json = nlohmann::json;
int
main
()
{
// a JSON text
std
::
string
text
=
R"(
auto
text
=
R"(
{
"Image": {
"Width": 800,
...
...
@@ -44,4 +44,4 @@ int main()
// parse (with callback) and serialize JSON
json
j_filtered
=
json
::
parse
(
text
,
cb
);
std
::
cout
<<
std
::
setw
(
4
)
<<
j_filtered
<<
'\n'
;
}
\ No newline at end of file
}
doc/examples/parse__string__parser_callback_t.link
View file @
b4571360
<a target="_blank" href="http://melpon.org/wandbox/permlink/SrKpkE9ivmvd2OUy"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="http://melpon.org/wandbox/permlink/n888UNQlMFduURhE"><b>online</b></a>
\ No newline at end of file
src/json.hpp
View file @
b4571360
This diff is collapsed.
Click to expand it.
src/json.hpp.re2c
View file @
b4571360
This diff is collapsed.
Click to expand it.
test/src/unit-class_parser.cpp
View file @
b4571360
...
...
@@ -477,7 +477,7 @@ TEST_CASE("parser class")
case
(
'r'
):
case
(
't'
):
{
CHECK_NOTHROW
(
json
::
parser
(
s
).
parse
());
CHECK_NOTHROW
(
json
::
parser
(
s
.
c_str
()
).
parse
());
break
;
}
...
...
@@ -490,8 +490,8 @@ TEST_CASE("parser class")
// any other combination of backslash and character is invalid
default:
{
CHECK_THROWS_AS
(
json
::
parser
(
s
).
parse
(),
std
::
invalid_argument
);
CHECK_THROWS_WITH
(
json
::
parser
(
s
).
parse
(),
"parse error - unexpected '
\"
'"
);
CHECK_THROWS_AS
(
json
::
parser
(
s
.
c_str
()
).
parse
(),
std
::
invalid_argument
);
CHECK_THROWS_WITH
(
json
::
parser
(
s
.
c_str
()
).
parse
(),
"parse error - unexpected '
\"
'"
);
break
;
}
}
...
...
@@ -549,22 +549,22 @@ TEST_CASE("parser class")
if
(
valid
(
c
))
{
CHECK_NOTHROW
(
json
::
parser
(
s1
).
parse
());
CHECK_NOTHROW
(
json
::
parser
(
s2
).
parse
());
CHECK_NOTHROW
(
json
::
parser
(
s3
).
parse
());
CHECK_NOTHROW
(
json
::
parser
(
s4
).
parse
());
CHECK_NOTHROW
(
json
::
parser
(
s1
.
c_str
()
).
parse
());
CHECK_NOTHROW
(
json
::
parser
(
s2
.
c_str
()
).
parse
());
CHECK_NOTHROW
(
json
::
parser
(
s3
.
c_str
()
).
parse
());
CHECK_NOTHROW
(
json
::
parser
(
s4
.
c_str
()
).
parse
());
}
else
{
CHECK_THROWS_AS
(
json
::
parser
(
s1
).
parse
(),
std
::
invalid_argument
);
CHECK_THROWS_AS
(
json
::
parser
(
s2
).
parse
(),
std
::
invalid_argument
);
CHECK_THROWS_AS
(
json
::
parser
(
s3
).
parse
(),
std
::
invalid_argument
);
CHECK_THROWS_AS
(
json
::
parser
(
s4
).
parse
(),
std
::
invalid_argument
);
CHECK_THROWS_WITH
(
json
::
parser
(
s1
).
parse
(),
"parse error - unexpected '
\"
'"
);
CHECK_THROWS_WITH
(
json
::
parser
(
s2
).
parse
(),
"parse error - unexpected '
\"
'"
);
CHECK_THROWS_WITH
(
json
::
parser
(
s3
).
parse
(),
"parse error - unexpected '
\"
'"
);
CHECK_THROWS_WITH
(
json
::
parser
(
s4
).
parse
(),
"parse error - unexpected '
\"
'"
);
CHECK_THROWS_AS
(
json
::
parser
(
s1
.
c_str
()
).
parse
(),
std
::
invalid_argument
);
CHECK_THROWS_AS
(
json
::
parser
(
s2
.
c_str
()
).
parse
(),
std
::
invalid_argument
);
CHECK_THROWS_AS
(
json
::
parser
(
s3
.
c_str
()
).
parse
(),
std
::
invalid_argument
);
CHECK_THROWS_AS
(
json
::
parser
(
s4
.
c_str
()
).
parse
(),
std
::
invalid_argument
);
CHECK_THROWS_WITH
(
json
::
parser
(
s1
.
c_str
()
).
parse
(),
"parse error - unexpected '
\"
'"
);
CHECK_THROWS_WITH
(
json
::
parser
(
s2
.
c_str
()
).
parse
(),
"parse error - unexpected '
\"
'"
);
CHECK_THROWS_WITH
(
json
::
parser
(
s3
.
c_str
()
).
parse
(),
"parse error - unexpected '
\"
'"
);
CHECK_THROWS_WITH
(
json
::
parser
(
s4
.
c_str
()
).
parse
(),
"parse error - unexpected '
\"
'"
);
}
}
}
...
...
test/src/unit-deserialization.cpp
View file @
b4571360
...
...
@@ -113,6 +113,12 @@ TEST_CASE("deserialization")
std
::
initializer_list
<
uint8_t
>
v
=
{
't'
,
'r'
,
'u'
,
'e'
,
'\0'
};
CHECK
(
json
::
parse
(
v
)
==
json
(
true
));
}
SECTION
(
"empty container"
)
{
std
::
vector
<
uint8_t
>
v
;
CHECK_THROWS_AS
(
json
::
parse
(
v
),
std
::
invalid_argument
);
}
}
SECTION
(
"via iterator range"
)
...
...
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