mirror of
https://github.com/nlohmann/json.git
synced 2026-02-17 09:03:58 +00:00
Compare commits
481 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f642934b18 | ||
|
|
6746a57524 | ||
|
|
eb08e8b09b | ||
|
|
4b5c61075f | ||
|
|
38e4935db0 | ||
|
|
cdde1a9436 | ||
|
|
d870826811 | ||
|
|
2f6260751c | ||
|
|
42fa3f0568 | ||
|
|
cd9701b123 | ||
|
|
1305e03557 | ||
|
|
77bb7af5d9 | ||
|
|
4d3053cd42 | ||
|
|
94d9b7bc86 | ||
|
|
ec03c9c53e | ||
|
|
4139bb6572 | ||
|
|
c154f3133d | ||
|
|
50a3f3b301 | ||
|
|
781fd09f2d | ||
|
|
daf8dcdb32 | ||
|
|
250e5bf43d | ||
|
|
030cf674ef | ||
|
|
3857e55290 | ||
|
|
9f103d19d7 | ||
|
|
9f8b270ed9 | ||
|
|
9c6ef74a28 | ||
|
|
ba0b35f414 | ||
|
|
37fd20b2eb | ||
|
|
7d771c71ed | ||
|
|
f997758cad | ||
|
|
40ba5a8b7b | ||
|
|
7f359017d2 | ||
|
|
708eb9613b | ||
|
|
889b269a4f | ||
|
|
a6b028286b | ||
|
|
d566bb81c4 | ||
|
|
1e20887cff | ||
|
|
447c6a670f | ||
|
|
3e15b551e0 | ||
|
|
fbac056c38 | ||
|
|
b56117b148 | ||
|
|
af94e712c7 | ||
|
|
1d87097741 | ||
|
|
e60e458a7e | ||
|
|
794dae8911 | ||
|
|
68081cd112 | ||
|
|
07bc82d3a7 | ||
|
|
f1482d1f01 | ||
|
|
f2c71fafda | ||
|
|
63e4249e9f | ||
|
|
b8012876a5 | ||
|
|
1554baa01d | ||
|
|
a9d5ae4fad | ||
|
|
e247e01a6e | ||
|
|
d0d8070422 | ||
|
|
e678c075dd | ||
|
|
cb3d455bd2 | ||
|
|
3494014ba0 | ||
|
|
1f25ec5d36 | ||
|
|
29f9fe6ae9 | ||
|
|
5839795725 | ||
|
|
b4cea6825d | ||
|
|
b2543e06d8 | ||
|
|
be6b417c87 | ||
|
|
317883b21b | ||
|
|
4e8089b9de | ||
|
|
7e6a6f978e | ||
|
|
c847e0eea2 | ||
|
|
6d427acdde | ||
|
|
f00898331e | ||
|
|
a32de3b528 | ||
|
|
d257149f36 | ||
|
|
bbe40641a3 | ||
|
|
6b89785fba | ||
|
|
c833b22b7b | ||
|
|
d359684f2b | ||
|
|
034d5ed97e | ||
|
|
be1d3de49b | ||
|
|
aa2679a8ce | ||
|
|
d5ee5830ed | ||
|
|
1c21c87e6f | ||
|
|
7e750ec1fa | ||
|
|
3d405c6883 | ||
|
|
8e43d476d3 | ||
|
|
f5cb089f89 | ||
|
|
1eafac7220 | ||
|
|
c0c72b5b62 | ||
|
|
60e6f822fa | ||
|
|
e5999c6c82 | ||
|
|
74bb11d92c | ||
|
|
907484fb43 | ||
|
|
47bc402113 | ||
|
|
ee19acaf05 | ||
|
|
9b401972a0 | ||
|
|
e2dbe7a69f | ||
|
|
0d91113ccf | ||
|
|
88819449c2 | ||
|
|
23bd2bce35 | ||
|
|
178441cdfd | ||
|
|
2bc685f6b4 | ||
|
|
837b81d672 | ||
|
|
33abccf847 | ||
|
|
7dc268ef42 | ||
|
|
4cdc61e493 | ||
|
|
03b391c37b | ||
|
|
12b4555b13 | ||
|
|
877d96c1d8 | ||
|
|
d54d6bb84c | ||
|
|
fe628b585b | ||
|
|
b443edf49e | ||
|
|
ce0b3fe5a3 | ||
|
|
145188f264 | ||
|
|
69be3fa842 | ||
|
|
5e3f9c8969 | ||
|
|
e951d198f4 | ||
|
|
046f6da82f | ||
|
|
bae8e70137 | ||
|
|
87c5e32e1f | ||
|
|
a00149f8ee | ||
|
|
1ab26ab367 | ||
|
|
74cbd30cd0 | ||
|
|
a7f3938391 | ||
|
|
a9b4cb8bf8 | ||
|
|
3a9ccfac22 | ||
|
|
98ad3c3ac1 | ||
|
|
0f03543861 | ||
|
|
e9bbf5aaba | ||
|
|
dd45ba6f89 | ||
|
|
e1b89dd1d6 | ||
|
|
9f6c86f233 | ||
|
|
4765070318 | ||
|
|
cdd3b5a68c | ||
|
|
767637877b | ||
|
|
f8d640b185 | ||
|
|
245a69d554 | ||
|
|
ea4d71ee21 | ||
|
|
9755cc75b1 | ||
|
|
7e2c4b3ead | ||
|
|
69c615e127 | ||
|
|
4d3bf433b4 | ||
|
|
8b46eb8ec0 | ||
|
|
6a20790056 | ||
|
|
60b3703c62 | ||
|
|
d173517212 | ||
|
|
a3063c2419 | ||
|
|
db33629990 | ||
|
|
712529cd32 | ||
|
|
09b91406c6 | ||
|
|
ab7d55e7ae | ||
|
|
cf9bf2d913 | ||
|
|
ff3221a375 | ||
|
|
328eb55dc4 | ||
|
|
010ea126f3 | ||
|
|
d7029c37aa | ||
|
|
f7575dee94 | ||
|
|
42a8c64499 | ||
|
|
f0edab2363 | ||
|
|
383a29a924 | ||
|
|
871cebaf84 | ||
|
|
8381cd6020 | ||
|
|
e4c2829aea | ||
|
|
1dd99d04b6 | ||
|
|
888f5b9f60 | ||
|
|
55be721615 | ||
|
|
acb7e0558d | ||
|
|
e3b036348b | ||
|
|
1399abc583 | ||
|
|
e4cc62e653 | ||
|
|
6de9d4035a | ||
|
|
dbdcb3fec8 | ||
|
|
6e129fbfb7 | ||
|
|
f87f4c06f9 | ||
|
|
33be4e7f1f | ||
|
|
a084e90f39 | ||
|
|
048330b14b | ||
|
|
22a6b956e8 | ||
|
|
ad241a2260 | ||
|
|
6e8791912f | ||
|
|
69ed19e483 | ||
|
|
7107072f71 | ||
|
|
2cf0f299ad | ||
|
|
937cca762f | ||
|
|
91e45a8dd0 | ||
|
|
f78671de8e | ||
|
|
2e5208d5cd | ||
|
|
c6fbd305b0 | ||
|
|
38597ac628 | ||
|
|
57b32d9773 | ||
|
|
73b28e8f92 | ||
|
|
1178a8152a | ||
|
|
0fffbb8488 | ||
|
|
9952a3c456 | ||
|
|
0e55af23fc | ||
|
|
57afd293aa | ||
|
|
a507b9b46a | ||
|
|
36dc786106 | ||
|
|
706be50596 | ||
|
|
303e873ae8 | ||
|
|
f6f7fed99a | ||
|
|
f24e4f680e | ||
|
|
fe00b368ae | ||
|
|
2f94c30bad | ||
|
|
4e2fb1a533 | ||
|
|
dfafd2c259 | ||
|
|
92e28c3153 | ||
|
|
c3fac19692 | ||
|
|
3f089cab2b | ||
|
|
9b5411db57 | ||
|
|
f5d4a9c4eb | ||
|
|
703d4baf8b | ||
|
|
bd6422f583 | ||
|
|
1e981115c9 | ||
|
|
79fa8b2f41 | ||
|
|
dd3f4f9b92 | ||
|
|
447e01427d | ||
|
|
b8776e8613 | ||
|
|
f6c21a1f20 | ||
|
|
5402458ff5 | ||
|
|
a25d570040 | ||
|
|
ea7b40687b | ||
|
|
b2991950a5 | ||
|
|
e906933f39 | ||
|
|
a59eb4868a | ||
|
|
a9d7d315a5 | ||
|
|
446019aefd | ||
|
|
6fa4f96ba3 | ||
|
|
dc6fc3e079 | ||
|
|
fdce38fa79 | ||
|
|
e8c903294f | ||
|
|
41673e8fed | ||
|
|
98d6e6e523 | ||
|
|
7e5d6af5c1 | ||
|
|
f1b95d78f9 | ||
|
|
d99c230f51 | ||
|
|
6b84c4155c | ||
|
|
81a4272444 | ||
|
|
3a0f5398a2 | ||
|
|
b7e0c12966 | ||
|
|
17c9b17a7e | ||
|
|
aab9bbbb93 | ||
|
|
de289ea336 | ||
|
|
81c43dca6a | ||
|
|
3f14a09e73 | ||
|
|
74571d531c | ||
|
|
2c7946f2bc | ||
|
|
8f6bfe5b32 | ||
|
|
474da6b28f | ||
|
|
be973e52bb | ||
|
|
a1693bfe48 | ||
|
|
bc28942101 | ||
|
|
44c0f811b1 | ||
|
|
6c24caf282 | ||
|
|
4adb8a81bf | ||
|
|
60b7299fe1 | ||
|
|
8f563a5f81 | ||
|
|
5c811b91f1 | ||
|
|
ba3c5e1a25 | ||
|
|
c46b4ea990 | ||
|
|
e717492019 | ||
|
|
bd252b2a09 | ||
|
|
50f647c866 | ||
|
|
7b6bd585c1 | ||
|
|
d563c21afe | ||
|
|
ee0f23fdc6 | ||
|
|
286025497f | ||
|
|
aeb4f87a27 | ||
|
|
6ecff31b7f | ||
|
|
bc238124ee | ||
|
|
4c232fe12b | ||
|
|
a820d688eb | ||
|
|
56843eb7ba | ||
|
|
93589e630c | ||
|
|
2477b09cb9 | ||
|
|
f860f323be | ||
|
|
71c1232e32 | ||
|
|
36c79113fb | ||
|
|
e1f98fbfc0 | ||
|
|
a73f43a7a2 | ||
|
|
eef408e5fb | ||
|
|
87e088990b | ||
|
|
a8522f391a | ||
|
|
2773038cf9 | ||
|
|
a791af30b4 | ||
|
|
1ed510c232 | ||
|
|
f194db9aa6 | ||
|
|
c39c36e6ad | ||
|
|
472d0045ba | ||
|
|
1407bbf94c | ||
|
|
8014637ad1 | ||
|
|
dfc49e7afe | ||
|
|
4bd3b1b0ef | ||
|
|
e3450cac72 | ||
|
|
c3a610d32a | ||
|
|
25548f85c9 | ||
|
|
4bb41d065b | ||
|
|
5f4becb0f5 | ||
|
|
ed611119d9 | ||
|
|
6cc2d58d69 | ||
|
|
f620d74919 | ||
|
|
869f4c68d4 | ||
|
|
c34b41acd6 | ||
|
|
abce5c25bb | ||
|
|
43dbe02d5b | ||
|
|
edc81f3bc1 | ||
|
|
d362a07239 | ||
|
|
a9744f3937 | ||
|
|
0c9ab9427f | ||
|
|
05e916717b | ||
|
|
693bfe439b | ||
|
|
0d72767b3e | ||
|
|
56667af823 | ||
|
|
0a908ce8e2 | ||
|
|
b0f896558f | ||
|
|
425b9834a8 | ||
|
|
56671a88c6 | ||
|
|
5316f0fff2 | ||
|
|
1be73b903e | ||
|
|
d1e73ce954 | ||
|
|
543745a10e | ||
|
|
9ca00e4880 | ||
|
|
e385417047 | ||
|
|
6d2b5e3771 | ||
|
|
700977d73e | ||
|
|
79015b9d0a | ||
|
|
3716a2fbe8 | ||
|
|
737d43724f | ||
|
|
59c8343851 | ||
|
|
94c16b2c31 | ||
|
|
8f70525374 | ||
|
|
7adccde714 | ||
|
|
8d1e65f297 | ||
|
|
7b4e6cf705 | ||
|
|
a8136c578a | ||
|
|
b820bb3b1f | ||
|
|
b03bbe724d | ||
|
|
7da182472d | ||
|
|
42ea4fb751 | ||
|
|
2fdba9de19 | ||
|
|
a2808322c6 | ||
|
|
a29fcae409 | ||
|
|
3ebe28970a | ||
|
|
79d9fdc016 | ||
|
|
e310850353 | ||
|
|
8057782bb8 | ||
|
|
cb2d41e3a0 | ||
|
|
542a48a16a | ||
|
|
606098f45d | ||
|
|
d91067220f | ||
|
|
67b9f1936d | ||
|
|
bb9d87ad55 | ||
|
|
e7a60d8961 | ||
|
|
470197bd0b | ||
|
|
d3e7f9da67 | ||
|
|
97280bbcfc | ||
|
|
e9fde3e116 | ||
|
|
54bf5f20e9 | ||
|
|
2fa8ea0f74 | ||
|
|
a0ef5a194c | ||
|
|
04b11d78ff | ||
|
|
8173c370f6 | ||
|
|
b6550b35c3 | ||
|
|
b5128b1610 | ||
|
|
963efb1f09 | ||
|
|
d6005e59a5 | ||
|
|
e1b6a23049 | ||
|
|
be61091401 | ||
|
|
e4366688f7 | ||
|
|
5dfd2c9bdf | ||
|
|
5879eb0be3 | ||
|
|
3d104f1d43 | ||
|
|
6bbcdc1ec5 | ||
|
|
7b6cba23f3 | ||
|
|
24c588cd25 | ||
|
|
f209be1142 | ||
|
|
768d66560e | ||
|
|
15925469c6 | ||
|
|
f922426ec3 | ||
|
|
2daab5a4c2 | ||
|
|
8ea0ee502d | ||
|
|
fa0299f03a | ||
|
|
36745ed296 | ||
|
|
f0455b401d | ||
|
|
e0d809312b | ||
|
|
bfd6678800 | ||
|
|
9639f0dfb3 | ||
|
|
625370a1ad | ||
|
|
357baeff5a | ||
|
|
42be2edd4c | ||
|
|
c8d01fa7b9 | ||
|
|
2c82f25272 | ||
|
|
df9fd6237e | ||
|
|
776880bc49 | ||
|
|
740b66f225 | ||
|
|
58cbf4b3ef | ||
|
|
ae7aaed4ac | ||
|
|
442058f8ed | ||
|
|
afba1d3fcb | ||
|
|
941714c99c | ||
|
|
a485aa8d27 | ||
|
|
6e6e1c9b1f | ||
|
|
f76f9efe58 | ||
|
|
463ffb21bc | ||
|
|
29c5f32d42 | ||
|
|
e0ff1a837c | ||
|
|
87dea32e81 | ||
|
|
bd3bd37e96 | ||
|
|
04c6c886eb | ||
|
|
8b833c452a | ||
|
|
1d66ab9f7a | ||
|
|
a79d634ccb | ||
|
|
6d1254baba | ||
|
|
b688119aa4 | ||
|
|
29a4ef6c5c | ||
|
|
71af209ea9 | ||
|
|
79fd4dfbd8 | ||
|
|
cda84ba323 | ||
|
|
034244a291 | ||
|
|
1e896eb91e | ||
|
|
94331a355d | ||
|
|
aa7f5ad8b1 | ||
|
|
585a39a235 | ||
|
|
b4571360df | ||
|
|
eef8059003 | ||
|
|
6f3554f040 | ||
|
|
0cf7ebaa57 | ||
|
|
d2564c6100 | ||
|
|
039cedaf8e | ||
|
|
628a5eae50 | ||
|
|
f40f81c87e | ||
|
|
c0922c7aac | ||
|
|
35f22e8596 | ||
|
|
a78eaa27b5 | ||
|
|
5e67f7af01 | ||
|
|
f791c5fd2e | ||
|
|
ca80a71c28 | ||
|
|
dfc2c1abe5 | ||
|
|
92ee1d56eb | ||
|
|
4871e39415 | ||
|
|
7b42c973bd | ||
|
|
c9e5d56c9c | ||
|
|
01386b3977 | ||
|
|
b76f5506d7 | ||
|
|
03de590372 | ||
|
|
37fdcd893d | ||
|
|
46174879ef | ||
|
|
5db41313ba | ||
|
|
1c4ca6d7b1 | ||
|
|
d02e67d4a9 | ||
|
|
ce30526ee8 | ||
|
|
efe1d52629 | ||
|
|
a2e923de32 | ||
|
|
4d90331718 | ||
|
|
997bc5d1ab | ||
|
|
31963723d3 | ||
|
|
407e8dbb8e | ||
|
|
b1c1fe9d39 | ||
|
|
b76861dde5 | ||
|
|
6150ffb9dc | ||
|
|
be05dbe618 | ||
|
|
4b37082e36 | ||
|
|
117fd59abd | ||
|
|
ff612e0e39 | ||
|
|
0b34ddd47a | ||
|
|
fa4fd334b2 | ||
|
|
d3c6ed08d6 | ||
|
|
00046f6ff1 | ||
|
|
38f562af2a | ||
|
|
2d3374c8b2 | ||
|
|
bd75ef9f27 | ||
|
|
ff592c6d50 | ||
|
|
91b6e223d9 | ||
|
|
d80329034e | ||
|
|
3944ecd470 | ||
|
|
be5cf0e3ba | ||
|
|
5541e6f6f9 | ||
|
|
263e6af48d | ||
|
|
4444ef9396 | ||
|
|
3586767c05 | ||
|
|
8b39570009 | ||
|
|
e29d6b5f41 | ||
|
|
25ccf7f908 |
24
.doozer.json
Normal file
24
.doozer.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"targets": {
|
||||
"xenial-i386": {
|
||||
"buildenv": "xenial-i386",
|
||||
"builddeps": ["build-essential", "cmake"],
|
||||
"buildcmd": ["mkdir cm", "cd cm", "cmake ..", "cmake --build .", "ctest --output-on-failure"]
|
||||
},
|
||||
"xenial-amd64": {
|
||||
"buildenv": "xenial-amd64",
|
||||
"builddeps": ["build-essential", "cmake"],
|
||||
"buildcmd": ["mkdir cm", "cd cm", "cmake ..", "cmake --build .", "ctest --output-on-failure"]
|
||||
},
|
||||
"fedora24-x86_64": {
|
||||
"buildenv": "fedora24-x86_64",
|
||||
"builddeps": ["cmake", "make", "clang"],
|
||||
"buildcmd": ["mkdir cm", "cd cm", "CXX=clang++ cmake ..", "cmake --build .", "ctest --output-on-failure"]
|
||||
},
|
||||
"osx": {
|
||||
"buildenv": "osx",
|
||||
"builddeps": ["build-essential"],
|
||||
"buildcmd": ["make check"]
|
||||
}
|
||||
}
|
||||
}
|
||||
22
.github/CONTRIBUTING.md
vendored
22
.github/CONTRIBUTING.md
vendored
@@ -6,6 +6,10 @@ This project started as a little excuse to exercise some of the cool new C++11 f
|
||||
|
||||
To make it as easy as possible for you to contribute and for me to keep an overview, here are a few guidelines which should help us avoid all kinds of unnecessary work or disappointment. And of course, this document is subject to discussion, so please [create an issue](https://github.com/nlohmann/json/issues/new) or a pull request if you find a way to improve it!
|
||||
|
||||
## Private reports
|
||||
|
||||
Usually, all issues are tracked publicly on [Github](https://github.com/nlohmann/json/issues). If you want to make a private report (e.g., for a vulnerability or to attach an example that is not meant to be publisheed), please send an email to <mail@nlohmann.me>.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Please [create an issue](https://github.com/nlohmann/json/issues/new), assuming one does not already exist, and describe your concern. Note you need a [GitHub account](https://github.com/signup/free) for this.
|
||||
@@ -32,21 +36,15 @@ There are currently two files which need to be edited:
|
||||
make re2c
|
||||
```
|
||||
|
||||
To run [`re2c`](http://re2c.org) and generate/overwrite file `src/json.hpp` with your changes in file `src/json.hpp.re2c`.
|
||||
To run [`re2c`](http://re2c.org) and generate/overwrite file `src/json.hpp` with your changes in file `src/json.hpp.re2c`. We currently use re2c version 0.16. Please also use this version, because other re2c versions tend to create code that differs a lot from which makes diffs unusable.
|
||||
|
||||
|
||||
2. [`test/src/unit.cpp`](https://github.com/nlohmann/json/blob/master/test/unit.cpp) - This contains the [Catch](https://github.com/philsquared/Catch) unit tests which currently cover [100 %](https://coveralls.io/github/nlohmann/json) of the library's code.
|
||||
|
||||
If you add or change a feature, please also add a unit test to this file. The unit tests can be compiled with
|
||||
If you add or change a feature, please also add a unit test to this file. The unit tests can be compiled and executed with
|
||||
|
||||
```sh
|
||||
make
|
||||
```
|
||||
|
||||
and can be executed with
|
||||
|
||||
```sh
|
||||
./json_unit
|
||||
make check
|
||||
```
|
||||
|
||||
The test cases are also executed with several different compilers on [Travis](https://travis-ci.org/nlohmann/json) once you open a pull request.
|
||||
@@ -57,13 +55,17 @@ Please understand that I cannot accept pull requests changing only file `src/jso
|
||||
## Note
|
||||
|
||||
- If you open a pull request, the code will be automatically tested with [Valgrind](http://valgrind.org)'s Memcheck tool to detect memory leaks. Please be aware that the execution with Valgrind _may_ in rare cases yield different behavior than running the code directly. This can result in failing unit tests which run successfully without Valgrind.
|
||||
- There is a Makefile target `make pretty` which runs [Artistic Style](http://astyle.sourceforge.net) to fix indentation. If possible, run it before opening the pull request. Otherwise, we shall run it afterward.
|
||||
|
||||
## Please don't
|
||||
|
||||
- Only make changes to file `src/json.hpp` -- please read the paragraph above and understand why `src/json.hpp.re2c` exists.
|
||||
- Please do not only make changes to file `src/json.hpp` -- please read the paragraph above and understand why `src/json.hpp.re2c` exists.
|
||||
- The C++11 support varies between different **compilers** and versions. Please note the [list of supported compilers](https://github.com/nlohmann/json/blob/master/README.md#supported-compilers). Some compilers like GCC 4.8 (and earlier), Clang 3.3 (and earlier), or Microsoft Visual Studio 13.0 and earlier are known not to work due to missing or incomplete C++11 support. Please refrain from proposing changes that work around these compiler's limitations with `#ifdef`s or other means.
|
||||
- Specifically, I am aware of compilation problems with **Microsoft Visual Studio** (there even is an [issue label](https://github.com/nlohmann/json/issues?utf8=✓&q=label%3A%22visual+studio%22+) for these kind of bugs). I understand that even in 2016, complete C++11 support isn't there yet. But please also understand that I do not want to drop features or uglify the code just to make Microsoft's sub-standard compiler happy. The past has shown that there are ways to express the functionality such that the code compiles with the most recent MSVC - unfortunately, this is not the main objective of the project.
|
||||
- Please refrain from proposing changes that would **break [JSON](http://json.org) conformance**. If you propose a conformant extension of JSON to be supported by the library, please motivate this extension.
|
||||
- We shall not extend the library to **support comments**. There is quite some [controversy](https://www.reddit.com/r/programming/comments/4v6chu/why_json_doesnt_support_comments_douglas_crockford/) around this topic, and there were quite some [issues](https://github.com/nlohmann/json/issues/376) on this. We believe that JSON is fine without comments.
|
||||
- We do not preserve the **insertion order of object elements**. The [JSON standard](https://tools.ietf.org/html/rfc7159.html) defines objects as "an unordered collection of zero or more name/value pairs". To this end, this library does not preserve insertion order of name/value pairs. (In fact, keys will be traversed in alphabetical order as `std::map` with `std::less` is used by default.) Note this behavior conforms to the standard, and we shall not it to any other order.
|
||||
|
||||
- Please do not open pull requests that address **multiple issues**.
|
||||
|
||||
## Wanted
|
||||
|
||||
25
.gitignore
vendored
25
.gitignore
vendored
@@ -1,16 +1,31 @@
|
||||
json_unit
|
||||
json_benchmarks
|
||||
|
||||
fuzz-testing
|
||||
|
||||
*.dSYM
|
||||
*.o
|
||||
*.gcno
|
||||
*.gcda
|
||||
|
||||
working
|
||||
|
||||
html
|
||||
doc/xml
|
||||
doc/html
|
||||
me.nlohmann.json.docset
|
||||
|
||||
android
|
||||
doc/xml
|
||||
|
||||
benchmarks/files/numbers/*.json
|
||||
|
||||
.idea
|
||||
cmake-build-debug
|
||||
|
||||
|
||||
test/test-*
|
||||
.svn
|
||||
|
||||
test/thirdparty/Fuzzer/libFuzzer.a
|
||||
|
||||
test/parse_afl_fuzzer
|
||||
|
||||
test/parse_cbor_fuzzer
|
||||
|
||||
test/parse_msgpack_fuzzer
|
||||
|
||||
383
.travis.yml
383
.travis.yml
@@ -1,173 +1,274 @@
|
||||
#########################
|
||||
# project configuration #
|
||||
#########################
|
||||
|
||||
# C++ project
|
||||
language: cpp
|
||||
|
||||
dist: trusty
|
||||
sudo: required
|
||||
|
||||
|
||||
###################
|
||||
# global settings #
|
||||
###################
|
||||
|
||||
env:
|
||||
global:
|
||||
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
|
||||
# via the "travis encrypt" command using the project repo's public key
|
||||
- secure: "m89SSgE+ASLO38rSKx7MTXK3n5NkP9bIx95jwY71YEiuFzib30PDJ/DifKnXxBjvy/AkCGztErQRk/8ZCvq+4HXozU2knEGnL/RUitvlwbhzfh2D4lmS3BvWBGS3N3NewoPBrRmdcvnT0xjOGXxtZaJ3P74TkB9GBnlz/HmKORA="
|
||||
|
||||
# from http://stackoverflow.com/a/32127147/266378
|
||||
|
||||
################
|
||||
# build matrix #
|
||||
################
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-4.9', 'valgrind', 'python-pip', 'python-yaml']
|
||||
before_script:
|
||||
- pip install --user git+git://github.com/eddyxu/cpp-coveralls.git
|
||||
after_success:
|
||||
- make clean
|
||||
- touch src/json.hpp
|
||||
- make json_unit CXXFLAGS="-fprofile-arcs -ftest-coverage -std=c++11 -lstdc++" CXX=$COMPILER
|
||||
- ./json_unit "*"
|
||||
- coveralls --exclude test/src/catch.hpp --exclude test/src/unit.cpp --include src/json.hpp --gcov-options '\-lp' --gcov 'gcov-4.9'
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
env: COMPILER=g++-4.9
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
before_install: echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-certificates.crt
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-5', 'valgrind']
|
||||
coverity_scan:
|
||||
project:
|
||||
name: "nlohmann/json"
|
||||
description: "Build submitted via Travis CI"
|
||||
notification_email: niels.lohmann@gmail.com
|
||||
build_command_prepend: "make clean ; sudo cp $(which g++-5) $(which g++)"
|
||||
build_command: "make"
|
||||
branch_pattern: coverity_scan
|
||||
env: COMPILER=g++-5
|
||||
# Valgrind
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-6', 'valgrind']
|
||||
env: COMPILER=g++-6
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env:
|
||||
- COMPILER=g++-4.9
|
||||
- SPECIAL=valgrind
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: [g++-4.9, valgrind]
|
||||
after_success:
|
||||
- make check TEST_PREFIX="valgrind --error-exitcode=1 --leak-check=full " TEST_PATTERN=""
|
||||
|
||||
# from https://github.com/travis-ci/travis-ci/issues/6120
|
||||
- os: linux
|
||||
env:
|
||||
- LLVM_VERSION=3.8.0
|
||||
- LLVM_ARCHIVE_PATH=$HOME/clang+llvm.tar.xz
|
||||
- COMPILER=clang++
|
||||
- CPPFLAGS="-I $HOME/clang-$LLVM_VERSION/include/c++/v1"
|
||||
- CXXFLAGS=-lc++
|
||||
- PATH=$HOME/clang-$LLVM_VERSION/bin:$PATH
|
||||
- LD_LIBRARY_PATH=$HOME/clang-$LLVM_VERSION/lib:$LD_LIBRARY_PATH
|
||||
before_install:
|
||||
- wget http://llvm.org/releases/$LLVM_VERSION/clang+llvm-$LLVM_VERSION-x86_64-linux-gnu-ubuntu-14.04.tar.xz -O $LLVM_ARCHIVE_PATH
|
||||
- mkdir $HOME/clang-$LLVM_VERSION
|
||||
- tar xf $LLVM_ARCHIVE_PATH -C $HOME/clang-$LLVM_VERSION --strip-components 1
|
||||
# cLang sanitizer
|
||||
# note: sadly clang's libc++ has errors when running with sanitize,
|
||||
# so we use clang with gcc's libstdc++ which doesn't give those error.
|
||||
# that's why we need to install g++-6 to get the lastest version
|
||||
- os: linux
|
||||
env:
|
||||
- LLVM_VERSION=3.8.1
|
||||
- SPECIAL=sanitizer
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: g++-6
|
||||
compiler: clang
|
||||
before_script:
|
||||
- make clang_sanitize
|
||||
|
||||
# Clang 3.5 is not able to compile the code,
|
||||
# see https://travis-ci.org/nlohmann/json/jobs/126720186
|
||||
# cppcheck
|
||||
|
||||
# - os: linux
|
||||
# compiler: clang
|
||||
# addons:
|
||||
# apt:
|
||||
# sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
|
||||
# packages: ['clang-3.6', 'valgrind']
|
||||
# env: COMPILER=clang++-3.6
|
||||
#
|
||||
# - os: linux
|
||||
# compiler: clang
|
||||
# addons:
|
||||
# apt:
|
||||
# sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7']
|
||||
# packages: ['clang-3.7', 'valgrind']
|
||||
# env: COMPILER=clang++-3.7
|
||||
#
|
||||
# - os: linux
|
||||
# compiler: clang
|
||||
# addons:
|
||||
# apt:
|
||||
# sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.8']
|
||||
# packages: ['clang-3.8', 'valgrind']
|
||||
# env: COMPILER=clang++-3.8
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env:
|
||||
- COMPILER=g++-4.9
|
||||
- SPECIAL=cppcheck
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: [g++-4.9, cppcheck]
|
||||
after_success:
|
||||
- make cppcheck
|
||||
|
||||
# - os: linux
|
||||
# compiler: clang
|
||||
# addons:
|
||||
# apt:
|
||||
# sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise']
|
||||
# packages: ['clang-3.9', 'valgrind']
|
||||
# env: COMPILER=clang++-3.9
|
||||
# no exceptions
|
||||
|
||||
- os: osx
|
||||
osx_image: beta-xcode6.1
|
||||
compiler: clang
|
||||
env:
|
||||
- COMPILER=clang
|
||||
- CXXFLAGS=-lstdc++
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env:
|
||||
- COMPILER=g++-4.9
|
||||
- SPECIAL=no_exceptions
|
||||
- TEST_PATTERN=-e \"*\"
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: [g++-4.9, cppcheck]
|
||||
before_script:
|
||||
- CPPFLAGS="-DJSON_NOEXCEPTION" make
|
||||
|
||||
- os: osx
|
||||
osx_image: beta-xcode6.2
|
||||
compiler: clang
|
||||
env:
|
||||
- COMPILER=clang
|
||||
- CXXFLAGS=-lstdc++
|
||||
# Coveralls (http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/)
|
||||
|
||||
- os: osx
|
||||
osx_image: beta-xcode6.3
|
||||
compiler: clang
|
||||
env:
|
||||
- COMPILER=clang
|
||||
- CXXFLAGS=-lstdc++
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-4.9', 'ruby']
|
||||
before_script:
|
||||
- wget http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.11.orig.tar.gz
|
||||
- tar xf lcov_1.11.orig.tar.gz
|
||||
- sudo make -C lcov-1.11/ install
|
||||
- gem install coveralls-lcov
|
||||
- pip install --user cpp-coveralls
|
||||
after_success:
|
||||
- make clean
|
||||
- CXXFLAGS="--coverage -g -O0" CPPFLAGS="-DNDEBUG" make json_unit
|
||||
- test/json_unit "*"
|
||||
- coveralls --build-root test --exclude src/catch.hpp --exclude src/unit-algorithms.cpp --exclude src/unit-allocator.cpp --exclude src/unit-capacity.cpp --exclude src/unit-class_const_iterator.cpp --exclude src/unit-class_iterator.cpp --exclude src/unit-class_lexer.cpp --exclude src/unit-class_parser.cpp --exclude src/unit-comparison.cpp --exclude src/unit-concepts.cpp --exclude src/unit-constructor1.cpp --exclude src/unit-constructor2.cpp --exclude src/unit-convenience.cpp --exclude src/unit-conversions.cpp --exclude src/unit-deserialization.cpp --exclude src/unit-element_access1.cpp --exclude src/unit-element_access2.cpp --exclude src/unit-inspection.cpp --exclude src/unit-iterator_wrapper.cpp --exclude src/unit-iterators1.cpp --exclude src/unit-iterators2.cpp --exclude src/unit-json_patch.cpp --exclude src/unit-json_pointer.cpp --exclude src/unit-modifiers.cpp --exclude src/unit-pointer_access.cpp --exclude src/unit-readme.cpp --exclude src/unit-reference_access.cpp --exclude src/unit-regression.cpp --exclude src/unit-serialization.cpp --exclude src/unit-testsuites.cpp --exclude src/unit-unicode.cpp --include ../src/json.hpp --gcov-options '\-lp' --gcov 'gcov-4.9'
|
||||
- lcov --directory src --directory test/src --capture --output-file coverage.info --rc lcov_branch_coverage=1 --no-external
|
||||
- lcov --remove coverage.info 'test/src/*' --output-file coverage.info --rc lcov_branch_coverage=1
|
||||
- lcov --list coverage.info --rc lcov_branch_coverage=1
|
||||
- coveralls-lcov --repo-token F9bs4Nop10JRgqPQXRcifyQKYhb3FczkS coverage.info
|
||||
env:
|
||||
- COMPILER=g++-4.9
|
||||
- SPECIAL=coveralls
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode6.4
|
||||
compiler: clang
|
||||
env:
|
||||
- COMPILER=clang
|
||||
- CXXFLAGS=-lstdc++
|
||||
# Coverity (only for branch coverity_scan)
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode7.1
|
||||
compiler: clang
|
||||
env:
|
||||
- COMPILER=clang
|
||||
- CXXFLAGS=-lstdc++
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode7.2
|
||||
compiler: clang
|
||||
env:
|
||||
- COMPILER=clang
|
||||
- CXXFLAGS=-lstdc++
|
||||
- os: linux
|
||||
compiler: clang
|
||||
before_install: echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-certificates.crt
|
||||
addons:
|
||||
coverity_scan:
|
||||
project:
|
||||
name: "nlohmann/json"
|
||||
description: "Build submitted via Travis CI"
|
||||
notification_email: niels.lohmann@gmail.com
|
||||
build_command_prepend: "make clean"
|
||||
build_command: "make"
|
||||
branch_pattern: coverity_scan
|
||||
env:
|
||||
- LLVM_VERSION=3.6.0
|
||||
- SPECIAL=coverity
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode7.3
|
||||
compiler: clang
|
||||
env:
|
||||
- COMPILER=clang
|
||||
- CXXFLAGS=-lstdc++
|
||||
# OSX / Clang
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode8
|
||||
compiler: clang
|
||||
env:
|
||||
- COMPILER=clang
|
||||
- CXXFLAGS=-lstdc++
|
||||
- os: osx
|
||||
osx_image: xcode6.4
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode7.3
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode8
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode8.1
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode8.2
|
||||
|
||||
# Linux / GCC
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: COMPILER=g++-4.9
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: g++-4.9
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: COMPILER=g++-5
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: g++-5
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: COMPILER=g++-6
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: g++-6
|
||||
|
||||
# Linux / Clang
|
||||
|
||||
- os: linux
|
||||
env: LLVM_VERSION=3.6.0
|
||||
compiler: clang
|
||||
|
||||
- os: linux
|
||||
env: LLVM_VERSION=3.6.1
|
||||
compiler: clang
|
||||
|
||||
- os: linux
|
||||
env: LLVM_VERSION=3.6.2
|
||||
compiler: clang
|
||||
|
||||
- os: linux
|
||||
env: LLVM_VERSION=3.7.0
|
||||
compiler: clang
|
||||
|
||||
- os: linux
|
||||
env: LLVM_VERSION=3.7.1
|
||||
compiler: clang
|
||||
|
||||
- os: linux
|
||||
env: LLVM_VERSION=3.8.0
|
||||
compiler: clang
|
||||
|
||||
- os: linux
|
||||
env: LLVM_VERSION=3.8.1
|
||||
compiler: clang
|
||||
|
||||
#####################
|
||||
# installation step #
|
||||
#####################
|
||||
|
||||
# set directories to cache
|
||||
cache:
|
||||
directories:
|
||||
- ${TRAVIS_BUILD_DIR}/deps/llvm-3.6.2
|
||||
- ${TRAVIS_BUILD_DIR}/deps/llvm-3.6.1
|
||||
- ${TRAVIS_BUILD_DIR}/deps/llvm-3.6.0
|
||||
- ${TRAVIS_BUILD_DIR}/deps/llvm-3.7.0
|
||||
- ${TRAVIS_BUILD_DIR}/deps/llvm-3.7.1
|
||||
- ${TRAVIS_BUILD_DIR}/deps/llvm-3.8.0
|
||||
- ${TRAVIS_BUILD_DIR}/deps/llvm-3.8.1
|
||||
|
||||
|
||||
install:
|
||||
# create deps dir if not existing
|
||||
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
|
||||
- mkdir -p ${DEPS_DIR}
|
||||
|
||||
# make sure CXX is correctly set
|
||||
- if [[ "${COMPILER}" != "" ]]; then export CXX=${COMPILER}; fi
|
||||
|
||||
# install LLVM/clang when LLVM_VERSION is set
|
||||
- |
|
||||
if [[ "${LLVM_VERSION}" != "" ]]; then
|
||||
LLVM_DIR=${DEPS_DIR}/llvm-${LLVM_VERSION}
|
||||
if [[ -z "$(ls -A ${LLVM_DIR})" ]]; then
|
||||
travis_retry wget --quiet https://cmake.org/files/v3.6/cmake-3.6.1.tar.gz
|
||||
tar xfz cmake-3.6.1.tar.gz
|
||||
(cd cmake-3.6.1 && ./configure --prefix=${LLVM_DIR}/cmake && make install)
|
||||
export PATH="${LLVM_DIR}/cmake/bin:${PATH}"
|
||||
LLVM_URL="http://llvm.org/releases/${LLVM_VERSION}/llvm-${LLVM_VERSION}.src.tar.xz"
|
||||
LIBCXX_URL="http://llvm.org/releases/${LLVM_VERSION}/libcxx-${LLVM_VERSION}.src.tar.xz"
|
||||
LIBCXXABI_URL="http://llvm.org/releases/${LLVM_VERSION}/libcxxabi-${LLVM_VERSION}.src.tar.xz"
|
||||
CLANG_URL="http://llvm.org/releases/${LLVM_VERSION}/clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-ubuntu-14.04.tar.xz"
|
||||
mkdir -p ${LLVM_DIR} ${LLVM_DIR}/build ${LLVM_DIR}/projects/libcxx ${LLVM_DIR}/projects/libcxxabi ${LLVM_DIR}/clang
|
||||
travis_retry wget --quiet -O - ${LLVM_URL} | tar --strip-components=1 -xJ -C ${LLVM_DIR}
|
||||
travis_retry wget --quiet -O - ${LIBCXX_URL} | tar --strip-components=1 -xJ -C ${LLVM_DIR}/projects/libcxx
|
||||
travis_retry wget --quiet -O - ${LIBCXXABI_URL} | tar --strip-components=1 -xJ -C ${LLVM_DIR}/projects/libcxxabi
|
||||
travis_retry wget --quiet -O - ${CLANG_URL} | tar --strip-components=1 -xJ -C ${LLVM_DIR}/clang
|
||||
(cd ${LLVM_DIR}/build && cmake .. -DCMAKE_INSTALL_PREFIX=${LLVM_DIR}/install -DCMAKE_CXX_COMPILER=clang++)
|
||||
(cd ${LLVM_DIR}/build/projects/libcxx && make install -j2)
|
||||
(cd ${LLVM_DIR}/build/projects/libcxxabi && make install -j2)
|
||||
fi
|
||||
export CXXFLAGS="-nostdinc++ -isystem ${LLVM_DIR}/install/include/c++/v1"
|
||||
export LDFLAGS="-L ${LLVM_DIR}/install/lib -l c++ -l c++abi"
|
||||
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${LLVM_DIR}/install/lib"
|
||||
export PATH="${LLVM_DIR}/clang/bin:${PATH}"
|
||||
fi
|
||||
|
||||
################
|
||||
# build script #
|
||||
################
|
||||
|
||||
script:
|
||||
# show OS/compiler version
|
||||
- uname -a
|
||||
- $COMPILER --version
|
||||
- make CXX=$COMPILER
|
||||
- ./json_unit "*"
|
||||
- if [ `which valgrind` ]; then
|
||||
valgrind --error-exitcode=1 --leak-check=full ./json_unit ;
|
||||
fi
|
||||
- $CXX --version
|
||||
|
||||
# compile and execute unit tests
|
||||
- make check
|
||||
|
||||
# check if homebrew works (only checks develop branch)
|
||||
- if [ `which brew` ]; then
|
||||
brew update ;
|
||||
brew tap nlohmann/json ;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
# define the project
|
||||
project(nlohmann_json VERSION 2.0.2 LANGUAGES CXX)
|
||||
project(nlohmann_json VERSION 2.1.0 LANGUAGES CXX)
|
||||
|
||||
enable_testing()
|
||||
|
||||
@@ -31,7 +31,8 @@ endif()
|
||||
include(CMakePackageConfigHelpers)
|
||||
configure_package_config_file("cmake/config.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${JSON_CONFIG_FILENAME}"
|
||||
INSTALL_DESTINATION ${JSON_CONFIG_DESTINATION})
|
||||
INSTALL_DESTINATION ${JSON_CONFIG_DESTINATION}
|
||||
PATH_VARS JSON_INCLUDE_DESTINATION)
|
||||
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/${JSON_CONFIGVERSION_FILENAME}"
|
||||
VERSION ${PROJECT_VERSION}
|
||||
COMPATIBILITY SameMajorVersion)
|
||||
|
||||
388
ChangeLog.md
388
ChangeLog.md
@@ -1,14 +1,193 @@
|
||||
# Change Log
|
||||
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [v2.0.2](https://github.com/nlohmann/json/releases/tag/v2.0.2) (2016-07-30)
|
||||
## [v2.1.0](https://github.com/nlohmann/json/releases/tag/v2.1.0) (2017-01-28)
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.10...v2.1.0)
|
||||
|
||||
- Parsing multiple JSON objects from a string or stream [\#438](https://github.com/nlohmann/json/issues/438)
|
||||
- Use-of-uninitialized-value \(OSS-Fuzz issue 477\) [\#437](https://github.com/nlohmann/json/issues/437)
|
||||
- add `reserve` function for array to reserve memory before adding json values into it [\#436](https://github.com/nlohmann/json/issues/436)
|
||||
- Typo in examples page [\#434](https://github.com/nlohmann/json/issues/434)
|
||||
- avoid malformed json [\#433](https://github.com/nlohmann/json/issues/433)
|
||||
- How to add json objects to a map? [\#432](https://github.com/nlohmann/json/issues/432)
|
||||
- create json instance from raw json \(unsigned char\*\) [\#431](https://github.com/nlohmann/json/issues/431)
|
||||
- Getting std::invalid\_argument: stream error when following example [\#429](https://github.com/nlohmann/json/issues/429)
|
||||
- Forward declare-only header? [\#427](https://github.com/nlohmann/json/issues/427)
|
||||
- Implicit conversion from array to object [\#425](https://github.com/nlohmann/json/issues/425)
|
||||
- Automatic ordered JSON [\#424](https://github.com/nlohmann/json/issues/424)
|
||||
- error C4996: 'strerror' when reading file [\#422](https://github.com/nlohmann/json/issues/422)
|
||||
- Get an error - JSON pointer must be empty or begin with '/' [\#421](https://github.com/nlohmann/json/issues/421)
|
||||
- size parameter for parse\(\) [\#419](https://github.com/nlohmann/json/issues/419)
|
||||
- json.hpp forcibly defines GCC\_VERSION [\#417](https://github.com/nlohmann/json/issues/417)
|
||||
- Use-of-uninitialized-value \(OSS-Fuzz issue 377\) [\#416](https://github.com/nlohmann/json/issues/416)
|
||||
- Single char converted to ASCII code instead of string [\#413](https://github.com/nlohmann/json/issues/413)
|
||||
- How to know if a string was parsed as utf-8? [\#406](https://github.com/nlohmann/json/issues/406)
|
||||
- Overloaded += to add objects to an array makes no sense? [\#404](https://github.com/nlohmann/json/issues/404)
|
||||
- Finding a value in an array [\#399](https://github.com/nlohmann/json/issues/399)
|
||||
- add release information in static function [\#397](https://github.com/nlohmann/json/issues/397)
|
||||
- Optimize memory usage of json objects in combination with binary serialization [\#373](https://github.com/nlohmann/json/issues/373)
|
||||
- Conversion operators not considered [\#369](https://github.com/nlohmann/json/issues/369)
|
||||
- Append ".0" to serialized floating\_point values that are digits-only. [\#362](https://github.com/nlohmann/json/issues/362)
|
||||
- Add a customization point for user-defined types [\#328](https://github.com/nlohmann/json/issues/328)
|
||||
- Conformance report for reference [\#307](https://github.com/nlohmann/json/issues/307)
|
||||
- Document the best way to serialize/deserialize user defined types to json [\#298](https://github.com/nlohmann/json/issues/298)
|
||||
- Add StringView template typename to basic\_json [\#297](https://github.com/nlohmann/json/issues/297)
|
||||
- \[Improvement\] Add option to remove exceptions [\#296](https://github.com/nlohmann/json/issues/296)
|
||||
- Performance in miloyip/nativejson-benchmark [\#202](https://github.com/nlohmann/json/issues/202)
|
||||
|
||||
- conversion from/to user-defined types [\#435](https://github.com/nlohmann/json/pull/435) ([nlohmann](https://github.com/nlohmann))
|
||||
- Fix documentation error [\#430](https://github.com/nlohmann/json/pull/430) ([vjon](https://github.com/vjon))
|
||||
|
||||
## [v2.0.10](https://github.com/nlohmann/json/releases/tag/v2.0.10) (2017-01-02)
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.9...v2.0.10)
|
||||
|
||||
- Heap-buffer-overflow \(OSS-Fuzz issue 367\) [\#412](https://github.com/nlohmann/json/issues/412)
|
||||
- Heap-buffer-overflow \(OSS-Fuzz issue 366\) [\#411](https://github.com/nlohmann/json/issues/411)
|
||||
- Use-of-uninitialized-value \(OSS-Fuzz issue 347\) [\#409](https://github.com/nlohmann/json/issues/409)
|
||||
- Heap-buffer-overflow \(OSS-Fuzz issue 344\) [\#408](https://github.com/nlohmann/json/issues/408)
|
||||
- Heap-buffer-overflow \(OSS-Fuzz issue 343\) [\#407](https://github.com/nlohmann/json/issues/407)
|
||||
- Heap-buffer-overflow \(OSS-Fuzz issue 342\) [\#405](https://github.com/nlohmann/json/issues/405)
|
||||
- strerror throwing error in compiler VS2015 [\#403](https://github.com/nlohmann/json/issues/403)
|
||||
- json::parse of std::string being underlined by Visual Studio [\#402](https://github.com/nlohmann/json/issues/402)
|
||||
- Explicitly getting string without .dump\(\) [\#401](https://github.com/nlohmann/json/issues/401)
|
||||
- Possible to speed up json::parse? [\#398](https://github.com/nlohmann/json/issues/398)
|
||||
- the alphabetic order in the code influence console\_output. [\#396](https://github.com/nlohmann/json/issues/396)
|
||||
- Execute tests with clang sanitizers [\#394](https://github.com/nlohmann/json/issues/394)
|
||||
- Check if library can be used with ETL [\#361](https://github.com/nlohmann/json/issues/361)
|
||||
|
||||
- Feature/clang sanitize [\#410](https://github.com/nlohmann/json/pull/410) ([Daniel599](https://github.com/Daniel599))
|
||||
- Add Doozer build badge [\#400](https://github.com/nlohmann/json/pull/400) ([andoma](https://github.com/andoma))
|
||||
|
||||
## [v2.0.9](https://github.com/nlohmann/json/releases/tag/v2.0.9) (2016-12-16)
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.8...v2.0.9)
|
||||
|
||||
- \#pragma GCC diagnostic ignored "-Wdocumentation" [\#393](https://github.com/nlohmann/json/issues/393)
|
||||
- How to parse this json file and write separate sub object as json files? [\#392](https://github.com/nlohmann/json/issues/392)
|
||||
- Integer-overflow \(OSS-Fuzz issue 267\) [\#389](https://github.com/nlohmann/json/issues/389)
|
||||
- Implement indefinite-length types from RFC 7049 [\#387](https://github.com/nlohmann/json/issues/387)
|
||||
- template parameter "T" is not used in declaring the parameter types of function template [\#386](https://github.com/nlohmann/json/issues/386)
|
||||
- Serializing json instances containing already serialized string values without escaping [\#385](https://github.com/nlohmann/json/issues/385)
|
||||
- Add test cases from RFC 7049 [\#384](https://github.com/nlohmann/json/issues/384)
|
||||
- Add a table of contents to the README file [\#383](https://github.com/nlohmann/json/issues/383)
|
||||
- Update FAQ section in the guidelines for contributing [\#382](https://github.com/nlohmann/json/issues/382)
|
||||
- Allow for forward declaring nlohmann::json [\#381](https://github.com/nlohmann/json/issues/381)
|
||||
- Bug in overflow detection when parsing integers [\#380](https://github.com/nlohmann/json/issues/380)
|
||||
- A unique name to mention the library? [\#377](https://github.com/nlohmann/json/issues/377)
|
||||
- Support for comments. [\#376](https://github.com/nlohmann/json/issues/376)
|
||||
- Non-unique keys in objects. [\#375](https://github.com/nlohmann/json/issues/375)
|
||||
- Request: binary serialization/deserialization [\#358](https://github.com/nlohmann/json/issues/358)
|
||||
|
||||
- Replace class iterator and const\_iterator by using a single template class to reduce code. [\#395](https://github.com/nlohmann/json/pull/395) ([Bosswestfalen](https://github.com/Bosswestfalen))
|
||||
- Clang: quiet a warning [\#391](https://github.com/nlohmann/json/pull/391) ([jaredgrubb](https://github.com/jaredgrubb))
|
||||
- Fix issue \#380: Signed integer overflow check [\#390](https://github.com/nlohmann/json/pull/390) ([qwename](https://github.com/qwename))
|
||||
|
||||
## [v2.0.8](https://github.com/nlohmann/json/releases/tag/v2.0.8) (2016-12-02)
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.7...v2.0.8)
|
||||
|
||||
- Reading from file [\#374](https://github.com/nlohmann/json/issues/374)
|
||||
- Compiler warnings? [\#372](https://github.com/nlohmann/json/issues/372)
|
||||
- docs: how to release a json object in memory? [\#371](https://github.com/nlohmann/json/issues/371)
|
||||
- crash in dump [\#370](https://github.com/nlohmann/json/issues/370)
|
||||
- Coverity issue \(FORWARD\_NULL\) in lexer\(std::istream& s\) [\#368](https://github.com/nlohmann/json/issues/368)
|
||||
- json::parse on failed stream gets stuck [\#366](https://github.com/nlohmann/json/issues/366)
|
||||
- Performance improvements [\#365](https://github.com/nlohmann/json/issues/365)
|
||||
- 'to\_string' is not a member of 'std' [\#364](https://github.com/nlohmann/json/issues/364)
|
||||
- Optional comment support. [\#363](https://github.com/nlohmann/json/issues/363)
|
||||
- Loss of precision when serializing \<double\> [\#360](https://github.com/nlohmann/json/issues/360)
|
||||
- Crash in dump\(\) from a static object [\#359](https://github.com/nlohmann/json/issues/359)
|
||||
- json::parse\(...\) vs json j; j.parse\(...\) [\#357](https://github.com/nlohmann/json/issues/357)
|
||||
- Hi, is there any method to dump json to string with the insert order rather than alphabets [\#356](https://github.com/nlohmann/json/issues/356)
|
||||
- Provide an example of reading from an json with only a key that has an array of strings. [\#354](https://github.com/nlohmann/json/issues/354)
|
||||
- Request: access with default value. [\#353](https://github.com/nlohmann/json/issues/353)
|
||||
- {} and \[\] causes parser error. [\#352](https://github.com/nlohmann/json/issues/352)
|
||||
- Reading a JSON file into a JSON object [\#351](https://github.com/nlohmann/json/issues/351)
|
||||
- Request: 'emplace\_back' [\#349](https://github.com/nlohmann/json/issues/349)
|
||||
- Is it possible to stream data through the json parser without storing everything in memory? [\#347](https://github.com/nlohmann/json/issues/347)
|
||||
- pure virtual conversion operator [\#346](https://github.com/nlohmann/json/issues/346)
|
||||
- Floating point precision lost [\#345](https://github.com/nlohmann/json/issues/345)
|
||||
- unit-conversions SIGSEGV on armv7hl [\#303](https://github.com/nlohmann/json/issues/303)
|
||||
- Coverity scan fails [\#299](https://github.com/nlohmann/json/issues/299)
|
||||
- Using QString as string type [\#274](https://github.com/nlohmann/json/issues/274)
|
||||
|
||||
## [v2.0.7](https://github.com/nlohmann/json/releases/tag/v2.0.7) (2016-11-02)
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.6...v2.0.7)
|
||||
|
||||
- JSON5 [\#348](https://github.com/nlohmann/json/issues/348)
|
||||
- Check "Parsing JSON is a Minefield" [\#344](https://github.com/nlohmann/json/issues/344)
|
||||
- Allow hex numbers [\#342](https://github.com/nlohmann/json/issues/342)
|
||||
- Convert strings to numbers [\#341](https://github.com/nlohmann/json/issues/341)
|
||||
- ""-operators ignore the length parameter [\#340](https://github.com/nlohmann/json/issues/340)
|
||||
- JSON into std::tuple [\#339](https://github.com/nlohmann/json/issues/339)
|
||||
- JSON into vector [\#335](https://github.com/nlohmann/json/issues/335)
|
||||
- Installing with Homebrew on Mac Errors \(El Capitan\) [\#331](https://github.com/nlohmann/json/issues/331)
|
||||
- g++ make check results in error [\#312](https://github.com/nlohmann/json/issues/312)
|
||||
- Cannot convert from 'json' to 'char' [\#276](https://github.com/nlohmann/json/issues/276)
|
||||
- Please add a Pretty-Print option for arrays to stay always in one line [\#229](https://github.com/nlohmann/json/issues/229)
|
||||
- Conversion to STL map\<string, vector\<int\>\> gives error [\#220](https://github.com/nlohmann/json/issues/220)
|
||||
- std::unorderd\_map cannot be used as ObjectType [\#164](https://github.com/nlohmann/json/issues/164)
|
||||
|
||||
- fix minor grammar/style issue in README.md [\#336](https://github.com/nlohmann/json/pull/336) ([seeekr](https://github.com/seeekr))
|
||||
|
||||
## [v2.0.6](https://github.com/nlohmann/json/releases/tag/v2.0.6) (2016-10-15)
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.5...v2.0.6)
|
||||
|
||||
- How to handle json files? [\#333](https://github.com/nlohmann/json/issues/333)
|
||||
- This file requires compiler and library support .... [\#332](https://github.com/nlohmann/json/issues/332)
|
||||
- Segmentation fault on saving json to file [\#326](https://github.com/nlohmann/json/issues/326)
|
||||
- parse error - unexpected \<uninitialized\> with 2.0.5 [\#325](https://github.com/nlohmann/json/issues/325)
|
||||
- Add nested object capability to pointers [\#323](https://github.com/nlohmann/json/issues/323)
|
||||
- Fix usage examples' comments for std::multiset [\#322](https://github.com/nlohmann/json/issues/322)
|
||||
- json\_unit runs forever when executed in build directory [\#319](https://github.com/nlohmann/json/issues/319)
|
||||
- Visual studio 2015 update3 true != TRUE [\#317](https://github.com/nlohmann/json/issues/317)
|
||||
- releasing single header file in compressed format [\#316](https://github.com/nlohmann/json/issues/316)
|
||||
- json object from std::ifstream [\#315](https://github.com/nlohmann/json/issues/315)
|
||||
|
||||
- make has\_mapped\_type struct friendly [\#324](https://github.com/nlohmann/json/pull/324) ([vpetrigo](https://github.com/vpetrigo))
|
||||
- Fix usage examples' comments for std::multiset [\#321](https://github.com/nlohmann/json/pull/321) ([vasild](https://github.com/vasild))
|
||||
- Include dir relocation [\#318](https://github.com/nlohmann/json/pull/318) ([ChristophJud](https://github.com/ChristophJud))
|
||||
- trivial documentation fix [\#313](https://github.com/nlohmann/json/pull/313) ([5tefan](https://github.com/5tefan))
|
||||
|
||||
## [v2.0.5](https://github.com/nlohmann/json/releases/tag/v2.0.5) (2016-09-14)
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.4...v2.0.5)
|
||||
|
||||
- \[feature request\]: schema validator and comments [\#311](https://github.com/nlohmann/json/issues/311)
|
||||
- make json\_benchmarks no longer working in 2.0.4 [\#310](https://github.com/nlohmann/json/issues/310)
|
||||
- Segmentation fault \(core dumped\) [\#309](https://github.com/nlohmann/json/issues/309)
|
||||
- No matching member function for call to 'get\_impl' [\#308](https://github.com/nlohmann/json/issues/308)
|
||||
|
||||
## [v2.0.4](https://github.com/nlohmann/json/releases/tag/v2.0.4) (2016-09-11)
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.3...v2.0.4)
|
||||
|
||||
- Parsing fails without space at end of file [\#306](https://github.com/nlohmann/json/issues/306)
|
||||
- json schema validator [\#305](https://github.com/nlohmann/json/issues/305)
|
||||
- Unused variable warning [\#304](https://github.com/nlohmann/json/issues/304)
|
||||
|
||||
## [v2.0.3](https://github.com/nlohmann/json/releases/tag/v2.0.3) (2016-08-31)
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.2...v2.0.3)
|
||||
|
||||
- warning C4706: assignment within conditional expression [\#295](https://github.com/nlohmann/json/issues/295)
|
||||
- Strip comments / Minify [\#294](https://github.com/nlohmann/json/issues/294)
|
||||
- Q: Is it possible to build json tree from already UTF8 encoded values? [\#293](https://github.com/nlohmann/json/issues/293)
|
||||
- Equality operator results in array when assigned object [\#292](https://github.com/nlohmann/json/issues/292)
|
||||
- Support for integers not from the range \[-\(2\*\*53\)+1, \(2\*\*53\)-1\] in parser [\#291](https://github.com/nlohmann/json/issues/291)
|
||||
- Support for iterator-range parsing [\#290](https://github.com/nlohmann/json/issues/290)
|
||||
- Horribly inconsistent behavior between const/non-const reference in operator \[\] \(\) [\#289](https://github.com/nlohmann/json/issues/289)
|
||||
- Silently get numbers into smaller types [\#288](https://github.com/nlohmann/json/issues/288)
|
||||
- Incorrect parsing of large int64\_t numbers [\#287](https://github.com/nlohmann/json/issues/287)
|
||||
- \[question\]: macro to disable floating point support [\#284](https://github.com/nlohmann/json/issues/284)
|
||||
|
||||
- unit-constructor1.cpp: Fix floating point truncation warning [\#300](https://github.com/nlohmann/json/pull/300) ([t-b](https://github.com/t-b))
|
||||
|
||||
## [v2.0.2](https://github.com/nlohmann/json/releases/tag/v2.0.2) (2016-07-31)
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.1...v2.0.2)
|
||||
|
||||
- can function dump\(\) return string in the order I push in the json object ? [\#286](https://github.com/nlohmann/json/issues/286)
|
||||
- Error on the Mac: Undefined symbols for architecture x86\_64 [\#285](https://github.com/nlohmann/json/issues/285)
|
||||
- value\(\) does not work with \_json\_pointer types [\#283](https://github.com/nlohmann/json/issues/283)
|
||||
- Easy serialization of classes [\#280](https://github.com/nlohmann/json/issues/280)
|
||||
|
||||
- Build error for std::int64 [\#282](https://github.com/nlohmann/json/issues/282)
|
||||
|
||||
- strings can't be accessed after dump\(\)-\>parse\(\) - type is lost [\#281](https://github.com/nlohmann/json/issues/281)
|
||||
- Easy serialization of classes [\#280](https://github.com/nlohmann/json/issues/280)
|
||||
- recursive data structures [\#277](https://github.com/nlohmann/json/issues/277)
|
||||
- hexify\(\) function emits conversion warning [\#270](https://github.com/nlohmann/json/issues/270)
|
||||
|
||||
- let the makefile choose the correct sed [\#279](https://github.com/nlohmann/json/pull/279) ([murinicanor](https://github.com/murinicanor))
|
||||
@@ -17,6 +196,7 @@ All notable changes to this project will be documented in this file. This projec
|
||||
## [v2.0.1](https://github.com/nlohmann/json/releases/tag/v2.0.1) (2016-06-28)
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.0...v2.0.1)
|
||||
|
||||
- Compilation error. [\#273](https://github.com/nlohmann/json/issues/273)
|
||||
- dump\(\) performance degradation in v2 [\#272](https://github.com/nlohmann/json/issues/272)
|
||||
|
||||
- fixed a tiny typo [\#271](https://github.com/nlohmann/json/pull/271) ([thelostt](https://github.com/thelostt))
|
||||
@@ -24,43 +204,61 @@ All notable changes to this project will be documented in this file. This projec
|
||||
## [v2.0.0](https://github.com/nlohmann/json/releases/tag/v2.0.0) (2016-06-23)
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v1.1.0...v2.0.0)
|
||||
|
||||
- concatenate objects [\#252](https://github.com/nlohmann/json/issues/252)
|
||||
- Unit test fails when doing a CMake out-of-tree build [\#241](https://github.com/nlohmann/json/issues/241)
|
||||
- Additional integration options [\#237](https://github.com/nlohmann/json/issues/237)
|
||||
- Can't use basic\_json::iterator as a base iterator for std::move\_iterator [\#233](https://github.com/nlohmann/json/issues/233)
|
||||
- Provide a FAQ [\#163](https://github.com/nlohmann/json/issues/163)
|
||||
- Create PULL\_REQUEST\_TEMPLATE.md [\#213](https://github.com/nlohmann/json/pull/213) ([whackashoe](https://github.com/whackashoe))
|
||||
- fixed noexcept; added constexpr [\#208](https://github.com/nlohmann/json/pull/208) ([nlohmann](https://github.com/nlohmann))
|
||||
- Add support for afl-fuzz testing [\#207](https://github.com/nlohmann/json/pull/207) ([mykter](https://github.com/mykter))
|
||||
- Issue \#178 - Extending support to full uint64\_t/int64\_t range and unsigned type \(updated\) [\#193](https://github.com/nlohmann/json/pull/193) ([twelsby](https://github.com/twelsby))
|
||||
|
||||
- json::diff generates incorrect patch when removing multiple array elements. [\#269](https://github.com/nlohmann/json/issues/269)
|
||||
- Docs - What does Json\[key\] return? [\#267](https://github.com/nlohmann/json/issues/267)
|
||||
- Compiler Errors With JSON.hpp [\#265](https://github.com/nlohmann/json/issues/265)
|
||||
- Throw exception instead of crashing my app [\#264](https://github.com/nlohmann/json/issues/264)
|
||||
- Ambiguous push\_back and operator+= overloads [\#263](https://github.com/nlohmann/json/issues/263)
|
||||
- Preseving order of items in json [\#262](https://github.com/nlohmann/json/issues/262)
|
||||
- '\' char problem in strings [\#261](https://github.com/nlohmann/json/issues/261)
|
||||
- VS2015 compile fail [\#260](https://github.com/nlohmann/json/issues/260)
|
||||
- -Wconversion warning [\#259](https://github.com/nlohmann/json/issues/259)
|
||||
- Maybe a bug [\#258](https://github.com/nlohmann/json/issues/258)
|
||||
- Few tests failed on Visual C++ 2015 [\#257](https://github.com/nlohmann/json/issues/257)
|
||||
- Access keys when iteration with new for loop C++11 [\#256](https://github.com/nlohmann/json/issues/256)
|
||||
- multiline text values [\#255](https://github.com/nlohmann/json/issues/255)
|
||||
- Error when using json in g++ [\#254](https://github.com/nlohmann/json/issues/254)
|
||||
- is the release 2.0? [\#253](https://github.com/nlohmann/json/issues/253)
|
||||
- concatenate objects [\#252](https://github.com/nlohmann/json/issues/252)
|
||||
- Encoding [\#251](https://github.com/nlohmann/json/issues/251)
|
||||
- Unable to build example for constructing json object with stringstreams [\#250](https://github.com/nlohmann/json/issues/250)
|
||||
- Hexadecimal support [\#249](https://github.com/nlohmann/json/issues/249)
|
||||
- Update long-term goals [\#246](https://github.com/nlohmann/json/issues/246)
|
||||
- Contribution To This Json Project [\#245](https://github.com/nlohmann/json/issues/245)
|
||||
- Trouble using parser with initial dictionary [\#243](https://github.com/nlohmann/json/issues/243)
|
||||
- Unit test fails when doing a CMake out-of-tree build [\#241](https://github.com/nlohmann/json/issues/241)
|
||||
- -Wconversion warnings [\#239](https://github.com/nlohmann/json/issues/239)
|
||||
- Additional integration options [\#237](https://github.com/nlohmann/json/issues/237)
|
||||
- .get\<std::string\>\(\) works for non spaced string but returns as array for spaced/longer strings [\#236](https://github.com/nlohmann/json/issues/236)
|
||||
- ambiguous overload for 'push\_back' and 'operator+=' [\#235](https://github.com/nlohmann/json/issues/235)
|
||||
- Can't use basic\_json::iterator as a base iterator for std::move\_iterator [\#233](https://github.com/nlohmann/json/issues/233)
|
||||
- json object's creation can freezes execution [\#231](https://github.com/nlohmann/json/issues/231)
|
||||
- Incorrect dumping of parsed numbers with exponents, but without decimal places [\#230](https://github.com/nlohmann/json/issues/230)
|
||||
- double values are serialized with commas as decimal points [\#228](https://github.com/nlohmann/json/issues/228)
|
||||
- Move semantics with std::initializer\_list [\#225](https://github.com/nlohmann/json/issues/225)
|
||||
- replace emplace [\#224](https://github.com/nlohmann/json/issues/224)
|
||||
- abort during getline in yyfill [\#223](https://github.com/nlohmann/json/issues/223)
|
||||
- free\(\): invalid pointer error in GCC 5.2.1 [\#221](https://github.com/nlohmann/json/issues/221)
|
||||
- Error compile Android NDK error: 'strtof' is not a member of 'std' [\#219](https://github.com/nlohmann/json/issues/219)
|
||||
- Wrong link in the README.md [\#217](https://github.com/nlohmann/json/issues/217)
|
||||
- Wide character strings not supported [\#216](https://github.com/nlohmann/json/issues/216)
|
||||
- Memory allocations using range-based for loops [\#214](https://github.com/nlohmann/json/issues/214)
|
||||
- would you like to support gcc 4.8.1? [\#211](https://github.com/nlohmann/json/issues/211)
|
||||
- Reading concatenated json's from an istream [\#210](https://github.com/nlohmann/json/issues/210)
|
||||
- Conflicting typedef of ssize\_t on Windows 32 bit when using Boost.Python [\#204](https://github.com/nlohmann/json/issues/204)
|
||||
- Inconsistency between operator\[\] and push\_back [\#203](https://github.com/nlohmann/json/issues/203)
|
||||
- Small bugs in json.hpp \(get\_number\) and unit.cpp \(non-standard integer type test\) [\#199](https://github.com/nlohmann/json/issues/199)
|
||||
- GCC/clang floating point parsing bug in strtod\(\) [\#195](https://github.com/nlohmann/json/issues/195)
|
||||
- What is within scope? [\#192](https://github.com/nlohmann/json/issues/192)
|
||||
- Bugs in miloyip/nativejson-benchmark: roundtrips [\#187](https://github.com/nlohmann/json/issues/187)
|
||||
- Floating point exceptions [\#181](https://github.com/nlohmann/json/issues/181)
|
||||
- In basic\_json::basic\_json\(const CompatibleArrayType& val\), the requirement of CompatibleArrayType is not strict enough. [\#174](https://github.com/nlohmann/json/issues/174)
|
||||
- Implicit assignment to std::string fails [\#144](https://github.com/nlohmann/json/issues/144)
|
||||
- Fix Issue \#265 [\#266](https://github.com/nlohmann/json/pull/266) ([06needhamt](https://github.com/06needhamt))
|
||||
- Issue \#195 - update Travis to Trusty due to gcc/clang strtod\(\) bug [\#196](https://github.com/nlohmann/json/pull/196) ([twelsby](https://github.com/twelsby))
|
||||
|
||||
- Compiler Errors With JSON.hpp [\#265](https://github.com/nlohmann/json/issues/265)
|
||||
- VS2015 compile fail [\#260](https://github.com/nlohmann/json/issues/260)
|
||||
- Error when using json in g++ [\#254](https://github.com/nlohmann/json/issues/254)
|
||||
- Update long-term goals [\#246](https://github.com/nlohmann/json/issues/246)
|
||||
- Error compile Android NDK error: 'strtof' is not a member of 'std' [\#219](https://github.com/nlohmann/json/issues/219)
|
||||
- Conflicting typedef of ssize\_t on Windows 32 bit when using Boost.Python [\#204](https://github.com/nlohmann/json/issues/204)
|
||||
- Integer conversion to unsigned [\#178](https://github.com/nlohmann/json/issues/178)
|
||||
- map string string fails to compile [\#176](https://github.com/nlohmann/json/issues/176)
|
||||
- In basic\_json::basic\_json\(const CompatibleArrayType& val\), the requirement of CompatibleArrayType is not strict enough. [\#174](https://github.com/nlohmann/json/issues/174)
|
||||
- Provide a FAQ [\#163](https://github.com/nlohmann/json/issues/163)
|
||||
- Implicit assignment to std::string fails [\#144](https://github.com/nlohmann/json/issues/144)
|
||||
|
||||
- Fix Issue \#265 [\#266](https://github.com/nlohmann/json/pull/266) ([06needhamt](https://github.com/06needhamt))
|
||||
- Define CMake/CTest tests [\#247](https://github.com/nlohmann/json/pull/247) ([robertmrk](https://github.com/robertmrk))
|
||||
- Out of tree builds and a few other miscellaneous CMake cleanups. [\#242](https://github.com/nlohmann/json/pull/242) ([ChrisKitching](https://github.com/ChrisKitching))
|
||||
- Implement additional integration options [\#238](https://github.com/nlohmann/json/pull/238) ([robertmrk](https://github.com/robertmrk))
|
||||
@@ -69,73 +267,81 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Use namespace std for int64\_t and uint64\_t [\#226](https://github.com/nlohmann/json/pull/226) ([lv-zheng](https://github.com/lv-zheng))
|
||||
- Added missing cerrno header to fix ERANGE compile error on android [\#222](https://github.com/nlohmann/json/pull/222) ([Teemperor](https://github.com/Teemperor))
|
||||
- Corrected readme [\#218](https://github.com/nlohmann/json/pull/218) ([Annihil](https://github.com/Annihil))
|
||||
- Create PULL\_REQUEST\_TEMPLATE.md [\#213](https://github.com/nlohmann/json/pull/213) ([whackashoe](https://github.com/whackashoe))
|
||||
- fixed noexcept; added constexpr [\#208](https://github.com/nlohmann/json/pull/208) ([nlohmann](https://github.com/nlohmann))
|
||||
- Add support for afl-fuzz testing [\#207](https://github.com/nlohmann/json/pull/207) ([mykter](https://github.com/mykter))
|
||||
- replaced ssize\_t occurrences with auto \(addresses \#204\) [\#205](https://github.com/nlohmann/json/pull/205) ([nlohmann](https://github.com/nlohmann))
|
||||
- Fixed issue \#199 - Small bugs in json.hpp \(get\_number\) and unit.cpp \(non-standard integer type test\) [\#200](https://github.com/nlohmann/json/pull/200) ([twelsby](https://github.com/twelsby))
|
||||
- Fix broken link [\#197](https://github.com/nlohmann/json/pull/197) ([vog](https://github.com/vog))
|
||||
- Issue \#195 - update Travis to Trusty due to gcc/clang strtod\(\) bug [\#196](https://github.com/nlohmann/json/pull/196) ([twelsby](https://github.com/twelsby))
|
||||
- Issue \#178 - Extending support to full uint64\_t/int64\_t range and unsigned type \(updated\) [\#193](https://github.com/nlohmann/json/pull/193) ([twelsby](https://github.com/twelsby))
|
||||
|
||||
## [v1.1.0](https://github.com/nlohmann/json/releases/tag/v1.1.0) (2016-01-24)
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v1.0.0...v1.1.0)
|
||||
|
||||
- JSON performance benchmark comparision [\#177](https://github.com/nlohmann/json/issues/177)
|
||||
- Since re2c is often ignored in pull requests, it may make sense to make a contributing.md file [\#175](https://github.com/nlohmann/json/issues/175)
|
||||
- Add assertions [\#168](https://github.com/nlohmann/json/issues/168)
|
||||
- range based for loop for objects [\#83](https://github.com/nlohmann/json/issues/83)
|
||||
- Implementation of get\_ref\(\) [\#184](https://github.com/nlohmann/json/pull/184) ([dariomt](https://github.com/dariomt))
|
||||
|
||||
- Small error in pull \#185 [\#194](https://github.com/nlohmann/json/issues/194)
|
||||
- Bugs in miloyip/nativejson-benchmark: floating-point parsing [\#186](https://github.com/nlohmann/json/issues/186)
|
||||
- Cannot index by key of type static constexpr const char\* [\#171](https://github.com/nlohmann/json/issues/171)
|
||||
- Fixed Issue \#171 - added two extra template overloads of operator\[\] for T\* arguments [\#189](https://github.com/nlohmann/json/pull/189) ([twelsby](https://github.com/twelsby))
|
||||
- Fixed issue \#167 - removed operator ValueType\(\) condition for VS2015 [\#188](https://github.com/nlohmann/json/pull/188) ([twelsby](https://github.com/twelsby))
|
||||
|
||||
- Floating point equality [\#185](https://github.com/nlohmann/json/issues/185)
|
||||
- Unused variables in catch [\#180](https://github.com/nlohmann/json/issues/180)
|
||||
- Typo in documentation [\#179](https://github.com/nlohmann/json/issues/179)
|
||||
- JSON performance benchmark comparision [\#177](https://github.com/nlohmann/json/issues/177)
|
||||
- Since re2c is often ignored in pull requests, it may make sense to make a contributing.md file [\#175](https://github.com/nlohmann/json/issues/175)
|
||||
- Question about exceptions [\#173](https://github.com/nlohmann/json/issues/173)
|
||||
- Android? [\#172](https://github.com/nlohmann/json/issues/172)
|
||||
- Cannot index by key of type static constexpr const char\* [\#171](https://github.com/nlohmann/json/issues/171)
|
||||
- Add assertions [\#168](https://github.com/nlohmann/json/issues/168)
|
||||
- MSVC 2015 build fails when attempting to compare object\_t [\#167](https://github.com/nlohmann/json/issues/167)
|
||||
- Member detector is not portable [\#166](https://github.com/nlohmann/json/issues/166)
|
||||
- Unnecessary const\_cast [\#162](https://github.com/nlohmann/json/issues/162)
|
||||
- Question about get\_ref\(\) [\#128](https://github.com/nlohmann/json/issues/128)
|
||||
- range based for loop for objects [\#83](https://github.com/nlohmann/json/issues/83)
|
||||
- Consider submitting this to the Boost Library Incubator [\#66](https://github.com/nlohmann/json/issues/66)
|
||||
|
||||
- Fixed Issue \#186 - add strto\(f|d|ld\) overload wrappers, "-0.0" special case and FP trailing zero [\#191](https://github.com/nlohmann/json/pull/191) ([twelsby](https://github.com/twelsby))
|
||||
- Issue \#185 - remove approx\(\) and use \#pragma to kill warnings [\#190](https://github.com/nlohmann/json/pull/190) ([twelsby](https://github.com/twelsby))
|
||||
- Fixed Issue \#171 - added two extra template overloads of operator\[\] for T\* arguments [\#189](https://github.com/nlohmann/json/pull/189) ([twelsby](https://github.com/twelsby))
|
||||
- Fixed issue \#167 - removed operator ValueType\(\) condition for VS2015 [\#188](https://github.com/nlohmann/json/pull/188) ([twelsby](https://github.com/twelsby))
|
||||
- Implementation of get\_ref\(\) [\#184](https://github.com/nlohmann/json/pull/184) ([dariomt](https://github.com/dariomt))
|
||||
- Fixed some typos in CONTRIBUTING.md [\#182](https://github.com/nlohmann/json/pull/182) ([nibroc](https://github.com/nibroc))
|
||||
|
||||
## [v1.0.0](https://github.com/nlohmann/json/releases/tag/v1.0.0) (2015-12-27)
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v1.0.0-rc1...v1.0.0)
|
||||
|
||||
- add key name to exception [\#160](https://github.com/nlohmann/json/issues/160)
|
||||
- prevent json.hpp from emitting compiler warnings [\#154](https://github.com/nlohmann/json/issues/154)
|
||||
- json::parse\(string\) does not check utf8 bom [\#152](https://github.com/nlohmann/json/issues/152)
|
||||
- unsigned 64bit values output as signed [\#151](https://github.com/nlohmann/json/issues/151)
|
||||
- Wish feature: json5 [\#150](https://github.com/nlohmann/json/issues/150)
|
||||
- overload of at\(\) with default value [\#133](https://github.com/nlohmann/json/issues/133)
|
||||
- Memory leak in face of exceptions [\#118](https://github.com/nlohmann/json/issues/118)
|
||||
- Find and Count for arrays [\#117](https://github.com/nlohmann/json/issues/117)
|
||||
- dynamically constructing an arbitrarily nested object [\#114](https://github.com/nlohmann/json/issues/114)
|
||||
- object field accessors [\#103](https://github.com/nlohmann/json/issues/103)
|
||||
- v8pp and json [\#95](https://github.com/nlohmann/json/issues/95)
|
||||
- Wishlist [\#65](https://github.com/nlohmann/json/issues/65)
|
||||
- Windows/Visual Studio \(through 2013\) is unsupported [\#62](https://github.com/nlohmann/json/issues/62)
|
||||
|
||||
- Bug in basic\_json::operator\[\] const overload [\#135](https://github.com/nlohmann/json/issues/135)
|
||||
- wrong enable\_if for const pointer \(instead of pointer-to-const\) [\#134](https://github.com/nlohmann/json/issues/134)
|
||||
- Visual Studio 14 Debug assertion failed [\#125](https://github.com/nlohmann/json/issues/125)
|
||||
- Compile error with g++ 4.9.3 cygwin 64-bit [\#112](https://github.com/nlohmann/json/issues/112)
|
||||
- error: unterminated raw string [\#109](https://github.com/nlohmann/json/issues/109)
|
||||
- \[clang-3.6.2\] string/sstream with number to json issue [\#107](https://github.com/nlohmann/json/issues/107)
|
||||
|
||||
- Getting member discarding qualifyer [\#159](https://github.com/nlohmann/json/issues/159)
|
||||
- basic\_json::iterator::value\(\) output includes quotes while basic\_json::iterator::key\(\) doesn't [\#158](https://github.com/nlohmann/json/issues/158)
|
||||
- Indexing `const basic\_json\<\>` with `const basic\_string\<char\>` [\#157](https://github.com/nlohmann/json/issues/157)
|
||||
- token\_type\_name\(token\_type t\): not all control paths return a value [\#156](https://github.com/nlohmann/json/issues/156)
|
||||
- prevent json.hpp from emitting compiler warnings [\#154](https://github.com/nlohmann/json/issues/154)
|
||||
- json::parse\(string\) does not check utf8 bom [\#152](https://github.com/nlohmann/json/issues/152)
|
||||
- unsigned 64bit values output as signed [\#151](https://github.com/nlohmann/json/issues/151)
|
||||
- Wish feature: json5 [\#150](https://github.com/nlohmann/json/issues/150)
|
||||
- Unable to compile on MSVC 2015 with SDL checking enabled: This function or variable may be unsafe. [\#149](https://github.com/nlohmann/json/issues/149)
|
||||
- "Json Object" type does not keep object order [\#148](https://github.com/nlohmann/json/issues/148)
|
||||
- dump\(\) convert strings encoded by utf-8 to shift-jis on windows 10. [\#147](https://github.com/nlohmann/json/issues/147)
|
||||
- Unable to get field names in a json object [\#145](https://github.com/nlohmann/json/issues/145)
|
||||
- Question: Is the use of incomplete type correct? [\#138](https://github.com/nlohmann/json/issues/138)
|
||||
- json.hpp:5746:32: error: 'to\_string' is not a member of 'std' [\#136](https://github.com/nlohmann/json/issues/136)
|
||||
- Bug in basic\_json::operator\[\] const overload [\#135](https://github.com/nlohmann/json/issues/135)
|
||||
- wrong enable\_if for const pointer \(instead of pointer-to-const\) [\#134](https://github.com/nlohmann/json/issues/134)
|
||||
- overload of at\(\) with default value [\#133](https://github.com/nlohmann/json/issues/133)
|
||||
- Splitting source [\#132](https://github.com/nlohmann/json/issues/132)
|
||||
- Question about get\_ptr\(\) [\#127](https://github.com/nlohmann/json/issues/127)
|
||||
- Visual Studio 14 Debug assertion failed [\#125](https://github.com/nlohmann/json/issues/125)
|
||||
- Memory leak in face of exceptions [\#118](https://github.com/nlohmann/json/issues/118)
|
||||
- Find and Count for arrays [\#117](https://github.com/nlohmann/json/issues/117)
|
||||
- dynamically constructing an arbitrarily nested object [\#114](https://github.com/nlohmann/json/issues/114)
|
||||
- Returning any data type [\#113](https://github.com/nlohmann/json/issues/113)
|
||||
- Compile error with g++ 4.9.3 cygwin 64-bit [\#112](https://github.com/nlohmann/json/issues/112)
|
||||
- insert json array issue with gcc4.8.2 [\#110](https://github.com/nlohmann/json/issues/110)
|
||||
- error: unterminated raw string [\#109](https://github.com/nlohmann/json/issues/109)
|
||||
- vector\<json\> copy constructor really weird [\#108](https://github.com/nlohmann/json/issues/108)
|
||||
- \[clang-3.6.2\] string/sstream with number to json issue [\#107](https://github.com/nlohmann/json/issues/107)
|
||||
- maintaining order of keys during iteration [\#106](https://github.com/nlohmann/json/issues/106)
|
||||
- object field accessors [\#103](https://github.com/nlohmann/json/issues/103)
|
||||
- v8pp and json [\#95](https://github.com/nlohmann/json/issues/95)
|
||||
- Wishlist [\#65](https://github.com/nlohmann/json/issues/65)
|
||||
- Windows/Visual Studio \(through 2013\) is unsupported [\#62](https://github.com/nlohmann/json/issues/62)
|
||||
|
||||
- Replace sprintf with hex function, this fixes \#149 [\#153](https://github.com/nlohmann/json/pull/153) ([whackashoe](https://github.com/whackashoe))
|
||||
- Fix character skipping after a surrogate pair [\#146](https://github.com/nlohmann/json/pull/146) ([robertmrk](https://github.com/robertmrk))
|
||||
@@ -151,65 +357,71 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Use the right variable name in doc string [\#115](https://github.com/nlohmann/json/pull/115) ([whoshuu](https://github.com/whoshuu))
|
||||
|
||||
## [v1.0.0-rc1](https://github.com/nlohmann/json/releases/tag/v1.0.0-rc1) (2015-07-26)
|
||||
- Finish documenting the public interface in Doxygen [\#102](https://github.com/nlohmann/json/issues/102)
|
||||
- Binary string causes numbers to be dumped as hex [\#101](https://github.com/nlohmann/json/issues/101)
|
||||
- failed to iterator json object with reverse\_iterator [\#100](https://github.com/nlohmann/json/issues/100)
|
||||
- 'noexcept' : unknown override specifier [\#99](https://github.com/nlohmann/json/issues/99)
|
||||
- json float parsing problem [\#98](https://github.com/nlohmann/json/issues/98)
|
||||
- Adjust wording to JSON RFC [\#97](https://github.com/nlohmann/json/issues/97)
|
||||
- 17 MB / 90 MB repo size!? [\#96](https://github.com/nlohmann/json/issues/96)
|
||||
- static analysis warnings [\#94](https://github.com/nlohmann/json/issues/94)
|
||||
- reverse\_iterator operator inheritance problem [\#93](https://github.com/nlohmann/json/issues/93)
|
||||
- init error [\#92](https://github.com/nlohmann/json/issues/92)
|
||||
- access by \(const\) reference [\#91](https://github.com/nlohmann/json/issues/91)
|
||||
- is\_integer and is\_float tests [\#90](https://github.com/nlohmann/json/issues/90)
|
||||
- Nonstandard integer type [\#89](https://github.com/nlohmann/json/issues/89)
|
||||
- static library build [\#84](https://github.com/nlohmann/json/issues/84)
|
||||
- lexer::get\_number return NAN [\#82](https://github.com/nlohmann/json/issues/82)
|
||||
- MinGW have no std::to\_string [\#80](https://github.com/nlohmann/json/issues/80)
|
||||
- Incorrect behaviour of basic\_json::count method [\#78](https://github.com/nlohmann/json/issues/78)
|
||||
- Invoking is\_array\(\) function creates "null" value [\#77](https://github.com/nlohmann/json/issues/77)
|
||||
- dump\(\) / parse\(\) not idempotent [\#76](https://github.com/nlohmann/json/issues/76)
|
||||
- Handle infinity and NaN cases [\#70](https://github.com/nlohmann/json/issues/70)
|
||||
- errors in g++-4.8.1 [\#68](https://github.com/nlohmann/json/issues/68)
|
||||
- Keys when iterating over objects [\#67](https://github.com/nlohmann/json/issues/67)
|
||||
- Compilation results in tons of warnings [\#64](https://github.com/nlohmann/json/issues/64)
|
||||
- Complete brief documentation [\#61](https://github.com/nlohmann/json/issues/61)
|
||||
- Double quotation mark is not parsed correctly [\#60](https://github.com/nlohmann/json/issues/60)
|
||||
- Get coverage back to 100% [\#58](https://github.com/nlohmann/json/issues/58)
|
||||
- erase elements using iterators [\#57](https://github.com/nlohmann/json/issues/57)
|
||||
- Removing item from array [\#56](https://github.com/nlohmann/json/issues/56)
|
||||
- Serialize/Deserialize like PHP? [\#55](https://github.com/nlohmann/json/issues/55)
|
||||
- Numbers as keys [\#54](https://github.com/nlohmann/json/issues/54)
|
||||
- Why are elements alphabetized on key while iterating? [\#53](https://github.com/nlohmann/json/issues/53)
|
||||
- Document erase, count, and iterators key and value [\#52](https://github.com/nlohmann/json/issues/52)
|
||||
- Do not use std::to\_string [\#51](https://github.com/nlohmann/json/issues/51)
|
||||
- Supported compilers [\#50](https://github.com/nlohmann/json/issues/50)
|
||||
- Confused about iterating through json objects [\#49](https://github.com/nlohmann/json/issues/49)
|
||||
- Use non-member begin/end [\#48](https://github.com/nlohmann/json/issues/48)
|
||||
- Erase key [\#47](https://github.com/nlohmann/json/issues/47)
|
||||
- Key iterator [\#46](https://github.com/nlohmann/json/issues/46)
|
||||
- Add count member function [\#45](https://github.com/nlohmann/json/issues/45)
|
||||
- Printing attribute names [\#39](https://github.com/nlohmann/json/issues/39)
|
||||
- Avoid using spaces when encoding without pretty print [\#31](https://github.com/nlohmann/json/issues/31)
|
||||
- Cannot encode long numbers [\#30](https://github.com/nlohmann/json/issues/30)
|
||||
- Creating an empty array [\#27](https://github.com/nlohmann/json/issues/27)
|
||||
- Custom allocator support [\#25](https://github.com/nlohmann/json/issues/25)
|
||||
- create a header-only version [\#16](https://github.com/nlohmann/json/issues/16)
|
||||
- Add to\_string overload for indentation [\#13](https://github.com/nlohmann/json/issues/13)
|
||||
- move code into namespace [\#9](https://github.com/nlohmann/json/issues/9)
|
||||
- free functions for explicit objects and arrays in initializer lists [\#8](https://github.com/nlohmann/json/issues/8)
|
||||
- Test case coverage [\#2](https://github.com/nlohmann/json/issues/2)
|
||||
- Parse streams incrementally. [\#40](https://github.com/nlohmann/json/pull/40) ([aburgh](https://github.com/aburgh))
|
||||
|
||||
- Binary string causes numbers to be dumped as hex [\#101](https://github.com/nlohmann/json/issues/101)
|
||||
- failed to iterator json object with reverse\_iterator [\#100](https://github.com/nlohmann/json/issues/100)
|
||||
- static analysis warnings [\#94](https://github.com/nlohmann/json/issues/94)
|
||||
- reverse\_iterator operator inheritance problem [\#93](https://github.com/nlohmann/json/issues/93)
|
||||
- Nonstandard integer type [\#89](https://github.com/nlohmann/json/issues/89)
|
||||
- lexer::get\_number return NAN [\#82](https://github.com/nlohmann/json/issues/82)
|
||||
- Handle infinity and NaN cases [\#70](https://github.com/nlohmann/json/issues/70)
|
||||
- errors in g++-4.8.1 [\#68](https://github.com/nlohmann/json/issues/68)
|
||||
- Double quotation mark is not parsed correctly [\#60](https://github.com/nlohmann/json/issues/60)
|
||||
- Do not use std::to\_string [\#51](https://github.com/nlohmann/json/issues/51)
|
||||
- Confused about iterating through json objects [\#49](https://github.com/nlohmann/json/issues/49)
|
||||
- Problem getting vector \(array\) of strings [\#44](https://github.com/nlohmann/json/issues/44)
|
||||
- Compilation error due to assuming that private=public [\#43](https://github.com/nlohmann/json/issues/43)
|
||||
- Use of deprecated implicit copy constructor [\#42](https://github.com/nlohmann/json/issues/42)
|
||||
- Printing attribute names [\#39](https://github.com/nlohmann/json/issues/39)
|
||||
- dumping a small number\_float just outputs 0.000000 [\#37](https://github.com/nlohmann/json/issues/37)
|
||||
- find is error [\#32](https://github.com/nlohmann/json/issues/32)
|
||||
- Avoid using spaces when encoding without pretty print [\#31](https://github.com/nlohmann/json/issues/31)
|
||||
- Cannot encode long numbers [\#30](https://github.com/nlohmann/json/issues/30)
|
||||
- segmentation fault when iterating over empty arrays/objects [\#28](https://github.com/nlohmann/json/issues/28)
|
||||
- Creating an empty array [\#27](https://github.com/nlohmann/json/issues/27)
|
||||
- Custom allocator support [\#25](https://github.com/nlohmann/json/issues/25)
|
||||
- make the type of the used string container customizable [\#20](https://github.com/nlohmann/json/issues/20)
|
||||
- Improper parsing of JSON string "\\" [\#17](https://github.com/nlohmann/json/issues/17)
|
||||
- create a header-only version [\#16](https://github.com/nlohmann/json/issues/16)
|
||||
- Don't return "const values" [\#15](https://github.com/nlohmann/json/issues/15)
|
||||
- Add to\_string overload for indentation [\#13](https://github.com/nlohmann/json/issues/13)
|
||||
- string parser does not recognize uncompliant strings [\#12](https://github.com/nlohmann/json/issues/12)
|
||||
- free functions for explicit objects and arrays in initializer lists [\#8](https://github.com/nlohmann/json/issues/8)
|
||||
- Runtime error in Travis job [\#1](https://github.com/nlohmann/json/issues/1)
|
||||
- Fix compilation of json\_unit with GCC 5 [\#59](https://github.com/nlohmann/json/pull/59) ([dkopecek](https://github.com/dkopecek))
|
||||
|
||||
- Finish documenting the public interface in Doxygen [\#102](https://github.com/nlohmann/json/issues/102)
|
||||
- 'noexcept' : unknown override specifier [\#99](https://github.com/nlohmann/json/issues/99)
|
||||
- Keys when iterating over objects [\#67](https://github.com/nlohmann/json/issues/67)
|
||||
- Complete brief documentation [\#61](https://github.com/nlohmann/json/issues/61)
|
||||
- Get coverage back to 100% [\#58](https://github.com/nlohmann/json/issues/58)
|
||||
- possible double-free in find function [\#11](https://github.com/nlohmann/json/issues/11)
|
||||
- UTF-8 encoding/deconding/testing [\#10](https://github.com/nlohmann/json/issues/10)
|
||||
- move code into namespace [\#9](https://github.com/nlohmann/json/issues/9)
|
||||
- free functions for explicit objects and arrays in initializer lists [\#8](https://github.com/nlohmann/json/issues/8)
|
||||
- unique\_ptr for ownership [\#7](https://github.com/nlohmann/json/issues/7)
|
||||
- Add unit tests [\#4](https://github.com/nlohmann/json/issues/4)
|
||||
- Drop C++98 support [\#3](https://github.com/nlohmann/json/issues/3)
|
||||
- Test case coverage [\#2](https://github.com/nlohmann/json/issues/2)
|
||||
- Runtime error in Travis job [\#1](https://github.com/nlohmann/json/issues/1)
|
||||
|
||||
- Keyword 'inline' is useless when member functions are defined in headers [\#87](https://github.com/nlohmann/json/pull/87) ([ahamez](https://github.com/ahamez))
|
||||
- Remove useless typename [\#86](https://github.com/nlohmann/json/pull/86) ([ahamez](https://github.com/ahamez))
|
||||
@@ -219,6 +431,8 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- support enum [\#71](https://github.com/nlohmann/json/pull/71) ([likebeta](https://github.com/likebeta))
|
||||
- Fix performance regression introduced with the parsing callback feature. [\#69](https://github.com/nlohmann/json/pull/69) ([aburgh](https://github.com/aburgh))
|
||||
- Improve the implementations of the comparission-operators [\#63](https://github.com/nlohmann/json/pull/63) ([Florianjw](https://github.com/Florianjw))
|
||||
- Fix compilation of json\_unit with GCC 5 [\#59](https://github.com/nlohmann/json/pull/59) ([dkopecek](https://github.com/dkopecek))
|
||||
- Parse streams incrementally. [\#40](https://github.com/nlohmann/json/pull/40) ([aburgh](https://github.com/aburgh))
|
||||
- Feature/small float serialization [\#38](https://github.com/nlohmann/json/pull/38) ([jrandall](https://github.com/jrandall))
|
||||
- template version with re2c scanner [\#36](https://github.com/nlohmann/json/pull/36) ([nlohmann](https://github.com/nlohmann))
|
||||
- more descriptive documentation in example [\#33](https://github.com/nlohmann/json/pull/33) ([luxe](https://github.com/luxe))
|
||||
|
||||
17
LICENSE.MIT
17
LICENSE.MIT
@@ -1,14 +1,13 @@
|
||||
The library is licensed under the MIT License
|
||||
<http://opensource.org/licenses/MIT>:
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2013-2016 Niels Lohmann
|
||||
Copyright (c) 2013-2017 Niels Lohmann
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
70
Makefile
70
Makefile
@@ -5,25 +5,31 @@ RE2C = re2c
|
||||
SED = sed
|
||||
|
||||
# main target
|
||||
all: json_unit
|
||||
all:
|
||||
$(MAKE) -C test
|
||||
|
||||
# clean up
|
||||
clean:
|
||||
rm -fr json_unit json_benchmarks fuzz fuzz-testing *.dSYM
|
||||
rm -fr json_unit json_benchmarks fuzz fuzz-testing *.dSYM test/*.dSYM
|
||||
rm -fr benchmarks/files/numbers/*.json
|
||||
$(MAKE) clean -Cdoc
|
||||
$(MAKE) clean -Ctest
|
||||
|
||||
|
||||
##########################################################################
|
||||
# unit tests
|
||||
##########################################################################
|
||||
|
||||
# additional flags
|
||||
FLAGS = -Wall -Wextra -pedantic -Weffc++ -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch -Wundef -Wno-unused -Wnon-virtual-dtor -Wreorder -Wdeprecated -Wfloat-equal
|
||||
# build unit tests
|
||||
json_unit:
|
||||
@$(MAKE) json_unit -C test
|
||||
|
||||
# build unit tests (TODO: Does this want its own makefile?)
|
||||
json_unit: test/src/unit.cpp src/json.hpp test/src/catch.hpp
|
||||
$(CXX) -std=c++11 $(CXXFLAGS) $(FLAGS) $(CPPFLAGS) -I src -I test $< $(LDFLAGS) -o $@
|
||||
# run unit tests
|
||||
check:
|
||||
$(MAKE) check -C test
|
||||
|
||||
check-fast:
|
||||
$(MAKE) check -C test TEST_PATTERN=""
|
||||
|
||||
|
||||
##########################################################################
|
||||
@@ -43,15 +49,40 @@ doctest:
|
||||
fuzz_testing:
|
||||
rm -fr fuzz-testing
|
||||
mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out
|
||||
$(MAKE) fuzz CXX=afl-clang++
|
||||
mv fuzz fuzz-testing
|
||||
$(MAKE) parse_afl_fuzzer -C test CXX=afl-clang++
|
||||
mv test/parse_afl_fuzzer fuzz-testing/fuzzer
|
||||
find test/data/json_tests -size -5k -name *json | xargs -I{} cp "{}" fuzz-testing/testcases
|
||||
@echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzz"
|
||||
@echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer"
|
||||
|
||||
# the fuzzer binary
|
||||
fuzz: test/src/fuzz.cpp src/json.hpp
|
||||
$(CXX) -std=c++11 $(CXXFLAGS) $(FLAGS) $(CPPFLAGS) -I src $< $(LDFLAGS) -o $@
|
||||
fuzz_testing_cbor:
|
||||
rm -fr fuzz-testing
|
||||
mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out
|
||||
$(MAKE) parse_cbor_fuzzer -C test CXX=afl-clang++
|
||||
mv test/parse_cbor_fuzzer fuzz-testing/fuzzer
|
||||
find test/data -size -5k -name *.cbor | xargs -I{} cp "{}" fuzz-testing/testcases
|
||||
@echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer"
|
||||
|
||||
fuzz_testing_msgpack:
|
||||
rm -fr fuzz-testing
|
||||
mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out
|
||||
$(MAKE) parse_msgpack_fuzzer -C test CXX=afl-clang++
|
||||
mv test/parse_msgpack_fuzzer fuzz-testing/fuzzer
|
||||
find test/data -size -5k -name *.msgpack | xargs -I{} cp "{}" fuzz-testing/testcases
|
||||
@echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer"
|
||||
|
||||
fuzzing-start:
|
||||
afl-fuzz -S fuzzer1 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null &
|
||||
afl-fuzz -S fuzzer2 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null &
|
||||
afl-fuzz -S fuzzer3 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null &
|
||||
afl-fuzz -S fuzzer4 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null &
|
||||
afl-fuzz -S fuzzer5 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null &
|
||||
afl-fuzz -S fuzzer6 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null &
|
||||
afl-fuzz -S fuzzer7 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null &
|
||||
afl-fuzz -M fuzzer0 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer
|
||||
|
||||
fuzzing-stop:
|
||||
-killall fuzzer
|
||||
-killall afl-fuzz
|
||||
|
||||
##########################################################################
|
||||
# static analyzer
|
||||
@@ -59,7 +90,11 @@ fuzz: test/src/fuzz.cpp src/json.hpp
|
||||
|
||||
# call cppcheck on the main header file
|
||||
cppcheck:
|
||||
cppcheck --enable=all --inconclusive --std=c++11 src/json.hpp
|
||||
cppcheck --enable=warning --inconclusive --force --std=c++11 src/json.hpp --error-exitcode=1
|
||||
|
||||
# run clang sanitize (we are overrding the CXXFLAGS provided by travis in order to use gcc's libstdc++)
|
||||
clang_sanitize: clean
|
||||
CXX=clang++ CXXFLAGS="-g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer" $(MAKE)
|
||||
|
||||
|
||||
##########################################################################
|
||||
@@ -68,7 +103,7 @@ cppcheck:
|
||||
|
||||
# create scanner with re2c
|
||||
re2c: src/json.hpp.re2c
|
||||
$(RE2C) -W --bit-vectors --nested-ifs --no-debug-info $< | $(SED) '1d' > src/json.hpp
|
||||
$(RE2C) -W --utf-8 --encoding-policy fail --bit-vectors --nested-ifs --no-debug-info $< | $(SED) '1d' > src/json.hpp
|
||||
|
||||
# pretty printer
|
||||
pretty:
|
||||
@@ -77,7 +112,8 @@ pretty:
|
||||
--indent-col1-comments --pad-oper --pad-header --align-pointer=type \
|
||||
--align-reference=type --add-brackets --convert-tabs --close-templates \
|
||||
--lineend=linux --preserve-date --suffix=none --formatted \
|
||||
src/json.hpp src/json.hpp.re2c test/src/unit.cpp test/src/fuzz.cpp benchmarks/benchmarks.cpp doc/examples/*.cpp
|
||||
src/json.hpp src/json.hpp.re2c test/src/*.cpp \
|
||||
benchmarks/benchmarks.cpp doc/examples/*.cpp
|
||||
|
||||
|
||||
##########################################################################
|
||||
@@ -87,7 +123,7 @@ pretty:
|
||||
# benchmarks
|
||||
json_benchmarks: benchmarks/benchmarks.cpp benchmarks/benchpress.hpp benchmarks/cxxopts.hpp src/json.hpp
|
||||
cd benchmarks/files/numbers ; python generate.py
|
||||
$(CXX) -std=c++11 $(CXXFLAGS) -O3 -flto -I src -I benchmarks $< $(LDFLAGS) -o $@
|
||||
$(CXX) -std=c++11 -pthread $(CXXFLAGS) -DNDEBUG -O3 -flto -I src -I benchmarks $< $(LDFLAGS) -o $@
|
||||
./json_benchmarks
|
||||
|
||||
|
||||
|
||||
391
README.md
391
README.md
@@ -1,30 +1,49 @@
|
||||
[](https://github.com/nlohmann/json/releases)
|
||||
|
||||
[](https://travis-ci.org/nlohmann/json)
|
||||
[](https://ci.appveyor.com/project/nlohmann/json)
|
||||
[](https://ci.appveyor.com/project/nlohmann/json)
|
||||
[](https://doozer.io/user/nlohmann/json)
|
||||
[](https://coveralls.io/r/nlohmann/json)
|
||||
[](https://scan.coverity.com/projects/nlohmann-json)
|
||||
[](http://melpon.org/wandbox/permlink/p5o4znPnGHJpDVqN)
|
||||
[](http://melpon.org/wandbox/permlink/4NEU6ZZMoM9lpIex)
|
||||
[](http://nlohmann.github.io/json)
|
||||
[](https://raw.githubusercontent.com/nlohmann/json/master/LICENSE.MIT)
|
||||
[](https://github.com/nlohmann/json/releases)
|
||||
[](http://github.com/nlohmann/json/issues)
|
||||
[](https://bestpractices.coreinfrastructure.org/projects/289)
|
||||
|
||||
- [Design goals](#design-goals)
|
||||
- [Integration](#integration)
|
||||
- [Examples](#examples)
|
||||
- [JSON as first-class data type](#json-as-first-class-data-type)
|
||||
- [Serialization / Deserialization](#serialization--deserialization)
|
||||
- [STL-like access](#stl-like-access)
|
||||
- [Conversion from STL containers](#conversion-from-stl-containers)
|
||||
- [JSON Pointer and JSON Patch](#json-pointer-and-json-patch)
|
||||
- [Implicit conversions](#implicit-conversions)
|
||||
- [Conversions to/from arbitrary types](#arbitrary-types-conversions)
|
||||
- [Binary formats (CBOR and MessagePack)](#binary-formats-cbor-and-messagepack)
|
||||
- [Supported compilers](#supported-compilers)
|
||||
- [License](#license)
|
||||
- [Thanks](#thanks)
|
||||
- [Notes](#notes)
|
||||
- [Execute unit tests](#execute-unit-tests)
|
||||
|
||||
## Design goals
|
||||
|
||||
There are myriads of [JSON](http://json.org) libraries out there, and each may even have its reason to exist. Our class had these design goals:
|
||||
|
||||
- **Intuitive syntax**. In languages such as Python, JSON feels like a first class data type. We used all the operator magic of modern C++ to achieve the same feeling in your code. Check out the [examples below](#examples) and you know, what I mean.
|
||||
- **Intuitive syntax**. In languages such as Python, JSON feels like a first class data type. We used all the operator magic of modern C++ to achieve the same feeling in your code. Check out the [examples below](#examples) and you'll know what I mean.
|
||||
|
||||
- **Trivial integration**. Our whole code consists of a single header file [`json.hpp`](https://github.com/nlohmann/json/blob/develop/src/json.hpp). That's it. No library, no subproject, no dependencies, no complex build system. The class is written in vanilla C++11. All in all, everything should require no adjustment of your compiler flags or project settings.
|
||||
|
||||
- **Serious testing**. Our class is heavily [unit-tested](https://github.com/nlohmann/json/blob/master/test/src/unit.cpp) and covers [100%](https://coveralls.io/r/nlohmann/json) of the code, including all exceptional behavior. Furthermore, we checked with [Valgrind](http://valgrind.org) that there are no memory leaks.
|
||||
- **Serious testing**. Our class is heavily [unit-tested](https://github.com/nlohmann/json/blob/master/test/src/unit.cpp) and covers [100%](https://coveralls.io/r/nlohmann/json) of the code, including all exceptional behavior. Furthermore, we checked with [Valgrind](http://valgrind.org) that there are no memory leaks. To maintain high quality, the project is following the [Core Infrastructure Initiative (CII) best practices](https://bestpractices.coreinfrastructure.org/projects/289).
|
||||
|
||||
Other aspects were not so important to us:
|
||||
|
||||
- **Memory efficiency**. Each JSON object has an overhead of one pointer (the maximal size of a union) and one enumeration element (1 byte). The default generalization uses the following C++ data types: `std::string` for strings, `int64_t`, `uint64_t` or `double` for numbers, `std::map` for objects, `std::vector` for arrays, and `bool` for Booleans. However, you can template the generalized class `basic_json` to your needs.
|
||||
|
||||
- **Speed**. We currently implement the parser as naive [recursive descent parser](http://en.wikipedia.org/wiki/Recursive_descent_parser) with hand coded string handling. It is fast enough, but a [LALR-parser](http://en.wikipedia.org/wiki/LALR_parser) may be even faster (but would consist of more files which makes the integration harder).
|
||||
- **Speed**. There are certainly [faster JSON libraries](https://github.com/miloyip/nativejson-benchmark#parsing-time) out there. However, if your goal is to speed up your development by adding JSON support with a single header, then this library is the way to go. If you know how to use a `std::vector` or `std::map`, you are already set.
|
||||
|
||||
See the [contribution guidelines](https://github.com/nlohmann/json/blob/master/.github/CONTRIBUTING.md#please-dont) for more information.
|
||||
|
||||
@@ -47,6 +66,10 @@ to the files you want to use JSON objects. That's it. Do not forget to set the n
|
||||
|
||||
## Examples
|
||||
|
||||
Beside the examples below, you may want to check the [documentation](https://nlohmann.github.io/json/) where each function contains a separate code example (e.g., check out [`emplace()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a602f275f0359ab181221384989810604.html#a602f275f0359ab181221384989810604)). All [example files](https://github.com/nlohmann/json/tree/develop/doc/examples) can be compiled and executed on their own (e.g., file [emplace.cpp](https://github.com/nlohmann/json/blob/develop/doc/examples/emplace.cpp)).
|
||||
|
||||
### JSON as first-class data type
|
||||
|
||||
Here are some examples to give you an idea how to use the class.
|
||||
|
||||
Assume you want to create the JSON object
|
||||
@@ -129,6 +152,8 @@ json array_not_object = { json::array({"currency", "USD"}), json::array({"value"
|
||||
|
||||
### Serialization / Deserialization
|
||||
|
||||
#### To/from strings
|
||||
|
||||
You can create an object (deserialization) by appending `_json` to a string literal:
|
||||
|
||||
```cpp
|
||||
@@ -162,6 +187,8 @@ std::cout << j.dump(4) << std::endl;
|
||||
// }
|
||||
```
|
||||
|
||||
#### To/from streams (e.g. files, string streams)
|
||||
|
||||
You can also use streams to serialize and deserialize:
|
||||
|
||||
```cpp
|
||||
@@ -176,10 +203,37 @@ std::cout << j;
|
||||
std::cout << std::setw(4) << j << std::endl;
|
||||
```
|
||||
|
||||
These operators work for any subclasses of `std::istream` or `std::ostream`.
|
||||
These operators work for any subclasses of `std::istream` or `std::ostream`. Here is the same example with files:
|
||||
|
||||
```cpp
|
||||
// read a JSON file
|
||||
std::ifstream i("file.json");
|
||||
json j;
|
||||
i >> j;
|
||||
|
||||
// write prettified JSON to another file
|
||||
std::ofstream o("pretty.json");
|
||||
o << std::setw(4) << j << std::endl;
|
||||
```
|
||||
|
||||
Please note that setting the exception bit for `failbit` is inappropriate for this use case. It will result in program termination due to the `noexcept` specifier in use.
|
||||
|
||||
#### Read from iterator range
|
||||
|
||||
You can also read JSON from an iterator range; that is, from any container accessible by iterators whose content is stored as contiguous byte sequence, for instance a `std::vector<uint8_t>`:
|
||||
|
||||
```cpp
|
||||
std::vector<uint8_t> v = {'t', 'r', 'u', 'e'};
|
||||
json j = json::parse(v.begin(), v.end());
|
||||
```
|
||||
|
||||
You may leave the iterators for the range [begin, end):
|
||||
|
||||
```cpp
|
||||
std::vector<uint8_t> v = {'t', 'r', 'u', 'e'};
|
||||
json j = json::parse(v);
|
||||
```
|
||||
|
||||
|
||||
### STL-like access
|
||||
|
||||
@@ -192,6 +246,9 @@ j.push_back("foo");
|
||||
j.push_back(1);
|
||||
j.push_back(true);
|
||||
|
||||
// also use emplace_back
|
||||
j.emplace_back(1.78);
|
||||
|
||||
// iterate the array
|
||||
for (json::iterator it = j.begin(); it != j.end(); ++it) {
|
||||
std::cout << *it << '\n';
|
||||
@@ -207,6 +264,9 @@ const std::string tmp = j[0];
|
||||
j[1] = 42;
|
||||
bool foo = j.at(2);
|
||||
|
||||
// comparison
|
||||
j == "[\"foo\", 1, true]"_json; // true
|
||||
|
||||
// other stuff
|
||||
j.size(); // 3 entries
|
||||
j.empty(); // false
|
||||
@@ -221,15 +281,15 @@ j.is_object();
|
||||
j.is_array();
|
||||
j.is_string();
|
||||
|
||||
// comparison
|
||||
j == "[\"foo\", 1, true]"_json; // true
|
||||
|
||||
// create an object
|
||||
json o;
|
||||
o["foo"] = 23;
|
||||
o["bar"] = false;
|
||||
o["baz"] = 3.141;
|
||||
|
||||
// also use emplace
|
||||
o.emplace("weather", "sunny");
|
||||
|
||||
// special iterator member functions for objects
|
||||
for (json::iterator it = o.begin(); it != o.end(); ++it) {
|
||||
std::cout << it.key() << " : " << it.value() << "\n";
|
||||
@@ -283,8 +343,8 @@ json j_uset(c_uset); // only one entry for "one" is used
|
||||
// maybe ["two", "three", "four", "one"]
|
||||
|
||||
std::multiset<std::string> c_mset {"one", "two", "one", "four"};
|
||||
json j_mset(c_mset); // only one entry for "one" is used
|
||||
// maybe ["one", "two", "four"]
|
||||
json j_mset(c_mset); // both entries for "one" are used
|
||||
// maybe ["one", "two", "one", "four"]
|
||||
|
||||
std::unordered_multiset<std::string> c_umset {"one", "two", "one", "four"};
|
||||
json j_umset(c_umset); // both entries for "one" are used
|
||||
@@ -383,6 +443,249 @@ int vi = jn.get<int>();
|
||||
// etc.
|
||||
```
|
||||
|
||||
### Arbitrary types conversions
|
||||
|
||||
Every type can be serialized in JSON, not just STL-containers and scalar types. Usually, you would do something along those lines:
|
||||
|
||||
```cpp
|
||||
namespace ns {
|
||||
// a simple struct to model a person
|
||||
struct person {
|
||||
std::string name;
|
||||
std::string address;
|
||||
int age;
|
||||
};
|
||||
}
|
||||
|
||||
ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
|
||||
|
||||
// convert to JSON: copy each value into the JSON object
|
||||
json j;
|
||||
j["name"] = p.name;
|
||||
j["address"] = p.address;
|
||||
j["age"] = p.age;
|
||||
|
||||
// ...
|
||||
|
||||
// convert from JSON: copy each value from the JSON object
|
||||
ns::person p {
|
||||
j["name"].get<std::string>(),
|
||||
j["address"].get<std::string>(),
|
||||
j["age"].get<int>()
|
||||
};
|
||||
```
|
||||
|
||||
It works, but that's quite a lot of boilerplate... Fortunately, there's a better way:
|
||||
|
||||
```cpp
|
||||
// create a person
|
||||
ns::person p {"Ned Flanders", "744 Evergreen Terrace", 60};
|
||||
|
||||
// conversion: person -> json
|
||||
json j = p;
|
||||
|
||||
std::cout << j << std::endl;
|
||||
// {"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"}
|
||||
|
||||
// conversion: json -> person
|
||||
ns::person p2 = j;
|
||||
|
||||
// that's it
|
||||
assert(p == p2);
|
||||
```
|
||||
|
||||
#### Basic usage
|
||||
|
||||
To make this work with one of your types, you only need to provide two functions:
|
||||
|
||||
```cpp
|
||||
using nlohmann::json;
|
||||
|
||||
namespace ns {
|
||||
void to_json(json& j, const person& p) {
|
||||
j = json{{"name", p.name}, {"address", p.address}, {"age", p.age}};
|
||||
}
|
||||
|
||||
void from_json(const json& j, person& p) {
|
||||
p.name = j["name"].get<std::string>();
|
||||
p.address = j["address"].get<std::string>();
|
||||
p.age = j["age"].get<int>();
|
||||
}
|
||||
} // namespace ns
|
||||
```
|
||||
|
||||
That's all! When calling the `json` constructor with your type, your custom `to_json` method will be automatically called.
|
||||
Likewise, when calling `get<your_type>()`, the `from_json` method will be called.
|
||||
|
||||
Some important things:
|
||||
|
||||
* Those methods **MUST** be in your type's namespace (which can be the global namespace), or the library will not be able to locate them (in this example, they are in namespace `ns`, where `person` is defined).
|
||||
* When using `get<your_type>()`, `your_type` **MUST** be [DefaultConstructible](http://en.cppreference.com/w/cpp/concept/DefaultConstructible). (There is a way to bypass this requirement described later.)
|
||||
|
||||
#### How do I convert third-party types?
|
||||
|
||||
This requires a bit more advanced technique. But first, let's see how this conversion mechanism works:
|
||||
|
||||
The library uses **JSON Serializers** to convert types to json.
|
||||
The default serializer for `nlohmann::json` is `nlohmann::adl_serializer` (ADL means [Argument-Dependent Lookup](http://en.cppreference.com/w/cpp/language/adl)).
|
||||
|
||||
It is implemented like this (simplified):
|
||||
|
||||
```cpp
|
||||
template <typename T>
|
||||
struct adl_serializer {
|
||||
static void to_json(json& j, const T& value) {
|
||||
// calls the "to_json" method in T's namespace
|
||||
}
|
||||
|
||||
static void from_json(const json& j, T& value) {
|
||||
// same thing, but with the "from_json" method
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
This serializer works fine when you have control over the type's namespace. However, what about `boost::optional`, or `std::filesystem::path` (C++17)? Hijacking the `boost` namespace is pretty bad, and it's illegal to add something other than template specializations to `std`...
|
||||
|
||||
To solve this, you need to add a specialization of `adl_serializer` to the `nlohmann` namespace, here's an example:
|
||||
|
||||
```cpp
|
||||
// partial specialization (full specialization works too)
|
||||
namespace nlohmann {
|
||||
template <typename T>
|
||||
struct adl_serializer<boost::optional<T>> {
|
||||
static void to_json(json& j, const boost::optional<T>& opt) {
|
||||
if (opt == boost::none) {
|
||||
j = nullptr;
|
||||
} else {
|
||||
j = *opt; // this will call adl_serializer<T>::to_json which will
|
||||
// find the free function to_json in T's namespace!
|
||||
}
|
||||
}
|
||||
|
||||
static void from_json(const json& j, boost::optional<T>& opt) {
|
||||
if (!j.is_null()) {
|
||||
opt = j.get<T>(); // same as above, but with
|
||||
// adl_serializer<T>::from_json
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
#### How can I use `get()` for non-default constructible/non-copyable types?
|
||||
|
||||
There is a way, if your type is [MoveConstructible](http://en.cppreference.com/w/cpp/concept/MoveConstructible). You will need to specialize the `adl_serializer` as well, but with a special `from_json` overload:
|
||||
|
||||
```cpp
|
||||
struct move_only_type {
|
||||
move_only_type() = delete;
|
||||
move_only_type(int ii): i(ii) {}
|
||||
move_only_type(const move_only_type&) = delete;
|
||||
move_only_type(move_only_type&&) = default;
|
||||
|
||||
int i;
|
||||
};
|
||||
|
||||
namespace nlohmann {
|
||||
template <>
|
||||
struct adl_serializer<move_only_type> {
|
||||
// note: the return type is no longer 'void', and the method only takes
|
||||
// one argument
|
||||
static move_only_type from_json(const json& j) {
|
||||
return {j.get<int>()};
|
||||
}
|
||||
|
||||
// Here's the catch! You must provide a to_json method! Otherwise you
|
||||
// will not be able to convert move_only_type to json, since you fully
|
||||
// specialized adl_serializer on that type
|
||||
static void to_json(json& j, move_only_type t) {
|
||||
j = t.i;
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
#### Can I write my own serializer? (Advanced use)
|
||||
|
||||
Yes. You might want to take a look at [`unit-udt.cpp`](https://github.com/nlohmann/json/blob/develop/test/src/unit-udt.cpp) in the test suite, to see a few examples.
|
||||
|
||||
If you write your own serializer, you'll need to do a few things:
|
||||
|
||||
* use a different `basic_json` alias than `nlohmann::json` (the last template parameter of `basic_json` is the `JSONSerializer`)
|
||||
* use your `basic_json` alias (or a template parameter) in all your `to_json`/`from_json` methods
|
||||
* use `nlohmann::to_json` and `nlohmann::from_json` when you need ADL
|
||||
|
||||
Here is an example, without simplifications, that only accepts types with a size <= 32, and uses ADL.
|
||||
|
||||
```cpp
|
||||
// You should use void as a second template argument
|
||||
// if you don't need compile-time checks on T
|
||||
template<typename T, typename SFINAE = typename std::enable_if<sizeof(T) <= 32>::type>
|
||||
struct less_than_32_serializer {
|
||||
template <typename BasicJsonType>
|
||||
static void to_json(BasicJsonType& j, T value) {
|
||||
// we want to use ADL, and call the correct to_json overload
|
||||
using nlohmann::to_json; // this method is called by adl_serializer,
|
||||
// this is where the magic happens
|
||||
to_json(j, value);
|
||||
}
|
||||
|
||||
template <typename BasicJsonType>
|
||||
static void from_json(const BasicJsonType& j, T& value) {
|
||||
// same thing here
|
||||
using nlohmann::from_json;
|
||||
from_json(j, value);
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
Be **very** careful when reimplementing your serializer, you can stack overflow if you don't pay attention:
|
||||
|
||||
```cpp
|
||||
template <typename T, void>
|
||||
struct bad_serializer
|
||||
{
|
||||
template <typename BasicJsonType>
|
||||
static void to_json(BasicJsonType& j, const T& value) {
|
||||
// this calls BasicJsonType::json_serializer<T>::to_json(j, value);
|
||||
// if BasicJsonType::json_serializer == bad_serializer ... oops!
|
||||
j = value;
|
||||
}
|
||||
|
||||
template <typename BasicJsonType>
|
||||
static void to_json(const BasicJsonType& j, T& value) {
|
||||
// this calls BasicJsonType::json_serializer<T>::from_json(j, value);
|
||||
// if BasicJsonType::json_serializer == bad_serializer ... oops!
|
||||
value = j.template get<T>(); // oops!
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
### Binary formats (CBOR and MessagePack)
|
||||
|
||||
Though JSON is a ubiquitous data format, it is not a very compact format suitable for data exchange, for instance over a network. Hence, the library supports [CBOR](http://cbor.io) (Concise Binary Object Representation) and [MessagePack](http://msgpack.org) to efficiently encode JSON values to byte vectors and to decode such vectors.
|
||||
|
||||
```cpp
|
||||
// create a JSON value
|
||||
json j = R"({"compact": true, "schema": 0})"_json;
|
||||
|
||||
// serialize to CBOR
|
||||
std::vector<uint8_t> v_cbor = json::to_cbor(j);
|
||||
|
||||
// 0xa2, 0x67, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, 0xf5, 0x66, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x00
|
||||
|
||||
// roundtrip
|
||||
json j_from_cbor = json::from_cbor(v_cbor);
|
||||
|
||||
// serialize to MessagePack
|
||||
std::vector<uint8_t> v_msgpack = json::to_msgpack(j);
|
||||
|
||||
// 0x82, 0xa7, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, 0xc3, 0xa6, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x00
|
||||
|
||||
// roundtrip
|
||||
json j_from_msgpack = json::from_msgpack(v_msgpack);
|
||||
```
|
||||
|
||||
|
||||
## Supported compilers
|
||||
|
||||
@@ -416,15 +719,18 @@ The following compilers are currently used in continuous integration at [Travis]
|
||||
| GCC 4.9.3 | Ubuntu 14.04.4 LTS | g++-4.9 (Ubuntu 4.9.3-8ubuntu2~14.04) 4.9.3 |
|
||||
| GCC 5.3.0 | Ubuntu 14.04.4 LTS | g++-5 (Ubuntu 5.3.0-3ubuntu1~14.04) 5.3.0 20151204 |
|
||||
| GCC 6.1.1 | Ubuntu 14.04.4 LTS | g++-6 (Ubuntu 6.1.1-3ubuntu11~14.04.1) 6.1.1 20160511 |
|
||||
| Clang 3.6.0 | Ubuntu 14.04.4 LTS | clang version 3.6.0 (tags/RELEASE_360/final) |
|
||||
| Clang 3.6.1 | Ubuntu 14.04.4 LTS | clang version 3.6.1 (tags/RELEASE_361/final) |
|
||||
| Clang 3.6.2 | Ubuntu 14.04.4 LTS | clang version 3.6.2 (tags/RELEASE_362/final) |
|
||||
| Clang 3.7.0 | Ubuntu 14.04.4 LTS | clang version 3.7.0 (tags/RELEASE_370/final) |
|
||||
| Clang 3.7.1 | Ubuntu 14.04.4 LTS | clang version 3.7.1 (tags/RELEASE_371/final) |
|
||||
| Clang 3.8.0 | Ubuntu 14.04.4 LTS | clang version 3.8.0 (tags/RELEASE_380/final) |
|
||||
| Clang Xcode 6.1 | Darwin Kernel Version 13.4.0 (OSX 10.9.5) | Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn) |
|
||||
| Clang Xcode 6.2 | Darwin Kernel Version 13.4.0 (OSX 10.9.5) | Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn) |
|
||||
| Clang Xcode 6.3 | Darwin Kernel Version 14.3.0 (OSX 10.10.3) | Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn) |
|
||||
| Clang 3.8.1 | Ubuntu 14.04.4 LTS | clang version 3.8.1 (tags/RELEASE_381/final) |
|
||||
| Clang Xcode 6.4 | Darwin Kernel Version 14.3.0 (OSX 10.10.3) | Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn) |
|
||||
| Clang Xcode 7.1 | Darwin Kernel Version 14.5.0 (OSX 10.10.5) | Apple LLVM version 7.0.0 (clang-700.1.76) |
|
||||
| Clang Xcode 7.2 | Darwin Kernel Version 15.0.0 (OSX 10.10.5) | Apple LLVM version 7.0.2 (clang-700.1.81) |
|
||||
| Clang Xcode 7.3 | Darwin Kernel Version 15.0.0 (OSX 10.10.5) | Apple LLVM version 7.3.0 (clang-703.0.29) |
|
||||
| Clang Xcode 8.0 | Darwin Kernel Version 15.5.0 (OSX 10.11.5) | Apple LLVM version 8.0.0 (clang-800.0.24.1) |
|
||||
| Clang Xcode 8.0 | Darwin Kernel Version 15.6.0 | Apple LLVM version 8.0.0 (clang-800.0.38) |
|
||||
| Clang Xcode 8.1 | Darwin Kernel Version 16.1.0 (macOS 10.12.1) | Apple LLVM version 8.0.0 (clang-800.0.42.1) |
|
||||
| Clang Xcode 8.2 | Darwin Kernel Version 16.1.0 (macOS 10.12.1) | Apple LLVM version 8.0.0 (clang-800.0.42.1) |
|
||||
| Visual Studio 14 2015 | Windows Server 2012 R2 (x64) | Microsoft (R) Build Engine version 14.0.25123.0 |
|
||||
|
||||
|
||||
@@ -434,7 +740,7 @@ The following compilers are currently used in continuous integration at [Travis]
|
||||
|
||||
The class is licensed under the [MIT License](http://opensource.org/licenses/MIT):
|
||||
|
||||
Copyright © 2013-2016 [Niels Lohmann](http://nlohmann.me)
|
||||
Copyright © 2013-2017 [Niels Lohmann](http://nlohmann.me)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
@@ -459,7 +765,7 @@ I deeply appreciate the help of the following people.
|
||||
- [Eric Cornelius](https://github.com/EricMCornelius) pointed out a bug in the handling with NaN and infinity values. He also improved the performance of the string escaping.
|
||||
- [易思龙](https://github.com/likebeta) implemented a conversion from anonymous enums.
|
||||
- [kepkin](https://github.com/kepkin) patiently pushed forward the support for Microsoft Visual studio.
|
||||
- [gregmarr](https://github.com/gregmarr) simplified the implementation of reverse iterators and helped with numerous hints and improvements.
|
||||
- [gregmarr](https://github.com/gregmarr) simplified the implementation of reverse iterators and helped with numerous hints and improvements. In particular, he pushed forward the implementation of user-defined types.
|
||||
- [Caio Luppi](https://github.com/caiovlp) fixed a bug in the Unicode handling.
|
||||
- [dariomt](https://github.com/dariomt) fixed some typos in the examples.
|
||||
- [Daniel Frey](https://github.com/d-frey) cleaned up some pointers and implemented exception-safe memory allocation.
|
||||
@@ -486,14 +792,41 @@ I deeply appreciate the help of the following people.
|
||||
- [Mário Feroldi](https://github.com/thelostt) fixed a small typo.
|
||||
- [duncanwerner](https://github.com/duncanwerner) found a really embarrassing performance regression in the 2.0.0 release.
|
||||
- [Damien](https://github.com/dtoma) fixed one of the last conversion warnings.
|
||||
- [Thomas Braun](https://github.com/t-b) fixed a warning in a test case.
|
||||
- [Théo DELRIEU](https://github.com/theodelrieu) patiently and constructively oversaw the long way toward [iterator-range parsing](https://github.com/nlohmann/json/issues/290). He also implemented the magic behind the serialization/deserialization of user-defined types.
|
||||
- [Stefan](https://github.com/5tefan) fixed a minor issue in the documentation.
|
||||
- [Vasil Dimov](https://github.com/vasild) fixed the documentation regarding conversions from `std::multiset`.
|
||||
- [ChristophJud](https://github.com/ChristophJud) overworked the CMake files to ease project inclusion.
|
||||
- [Vladimir Petrigo](https://github.com/vpetrigo) made a SFINAE hack more readable.
|
||||
- [Denis Andrejew](https://github.com/seeekr) fixed a grammar issue in the README file.
|
||||
- [Pierre-Antoine Lacaze](https://github.com/palacaze) found a subtle bug in the `dump()` function.
|
||||
- [TurpentineDistillery](https://github.com/TurpentineDistillery) pointed to [`std::locale::classic()`](http://en.cppreference.com/w/cpp/locale/locale/classic) to avoid too much locale joggling, found some nice performance improvements in the parser and improved the benchmarking code.
|
||||
- [cgzones](https://github.com/cgzones) had an idea how to fix the Coverity scan.
|
||||
- [Jared Grubb](https://github.com/jaredgrubb) silenced a nasty documentation warning.
|
||||
- [Yixin Zhang](https://github.com/qwename) fixed an integer overflow check.
|
||||
- [Bosswestfalen](https://github.com/Bosswestfalen) merged two iterator classes into a smaller one.
|
||||
- [Daniel599](https://github.com/Daniel599) helped to get Travis execute the tests with Clang's sanitizers.
|
||||
- [Jonathan Lee](https://github.com/vjon) fixed an example in the README file.
|
||||
- [gnzlbg](https://github.com/gnzlbg) supported the implementation of user-defined types.
|
||||
- [Alexej Harm](https://github.com/qis) helped to get the user-defined types working with Visual Studio.
|
||||
- [Jared Grubb](https://github.com/jaredgrubb) supported the implementation of user-defined types.
|
||||
- [EnricoBilla](https://github.com/EnricoBilla) noted a typo in an example.
|
||||
|
||||
Thanks a lot for helping out!
|
||||
Thanks a lot for helping out! Please [let me know](mailto:mail@nlohmann.me) if I forgot someone.
|
||||
|
||||
|
||||
## Notes
|
||||
|
||||
- The code contains numerous debug **assertions** which can be switched off by defining the preprocessor macro `NDEBUG`, see the [documentation of `assert`](http://en.cppreference.com/w/cpp/error/assert).
|
||||
- The code contains numerous debug **assertions** which can be switched off by defining the preprocessor macro `NDEBUG`, see the [documentation of `assert`](http://en.cppreference.com/w/cpp/error/assert). In particular, note [`operator[]`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a2e26bd0b0168abb61f67ad5bcd5b9fa1.html#a2e26bd0b0168abb61f67ad5bcd5b9fa1) implements **unchecked access** for const objects: If the given key is not present, the behavior is undefined (think of a dereferenced null pointer) and yields an [assertion failure](https://github.com/nlohmann/json/issues/289) if assertions are switched on. If you are not sure whether an element in an object exists, use checked access with the [`at()` function](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a674de1ee73e6bf4843fc5dc1351fb726.html#a674de1ee73e6bf4843fc5dc1351fb726).
|
||||
- As the exact type of a number is not defined in the [JSON specification](http://rfc7159.net/rfc7159), this library tries to choose the best fitting C++ number type automatically. As a result, the type `double` may be used to store numbers which may yield [**floating-point exceptions**](https://github.com/nlohmann/json/issues/181) in certain rare situations if floating-point exceptions have been unmasked in the calling code. These exceptions are not caused by the library and need to be fixed in the calling code, such as by re-masking the exceptions prior to calling library functions.
|
||||
- The library supports **Unicode input** as follows:
|
||||
- Only **UTF-8** encoded input is supported which is the default encoding for JSON according to [RFC 7159](http://rfc7159.net/rfc7159#rfc.section.8.1).
|
||||
- Other encodings such as Latin-1, UTF-16, or UTF-32 are not supported and will yield parse errors.
|
||||
- [Unicode noncharacters](http://www.unicode.org/faq/private_use.html#nonchar1) will not be replaced by the library.
|
||||
- Invalid surrogates (e.g., incomplete pairs such as `\uDEAD`) will yield parse errors.
|
||||
- The strings stored in the library are UTF-8 encoded. When using the default string type (`std::string`), note that its length/size functions return the number of stored bytes rather than the number of characters or glyphs.
|
||||
- The code can be compiled without C++ **runtime type identification** features; that is, you can use the `-fno-rtti` compiler flag.
|
||||
- **Exceptions** are used widly within the library. They can, however, be switched off with either using the compiler flag `-fno-exceptions` or by defining the symbol `JSON_NOEXCEPTION`. In this case, exceptions are replaced by an `abort()` call.
|
||||
|
||||
|
||||
## Execute unit tests
|
||||
@@ -501,11 +834,21 @@ Thanks a lot for helping out!
|
||||
To compile and run the tests, you need to execute
|
||||
|
||||
```sh
|
||||
$ make
|
||||
$ ./json_unit "*"
|
||||
$ make json_unit -Ctest
|
||||
$ ./test/json_unit "*""
|
||||
|
||||
===============================================================================
|
||||
All tests passed (8905012 assertions in 32 test cases)
|
||||
All tests passed (11202052 assertions in 47 test cases)
|
||||
```
|
||||
|
||||
Alternatively, you can use [CMake](https://cmake.org) and run
|
||||
|
||||
```sh
|
||||
$ mkdir build
|
||||
$ cd build
|
||||
$ cmake ..
|
||||
$ make
|
||||
$ ctest
|
||||
```
|
||||
|
||||
For more information, have a look at the file [.travis.yml](https://github.com/nlohmann/json/blob/master/.travis.yml).
|
||||
|
||||
@@ -1,107 +1,118 @@
|
||||
#define BENCHPRESS_CONFIG_MAIN
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <benchpress.hpp>
|
||||
#include <json.hpp>
|
||||
#include <pthread.h>
|
||||
#include <thread>
|
||||
|
||||
BENCHMARK("parse jeopardy.json", [](benchpress::context* ctx)
|
||||
using json = nlohmann::json;
|
||||
|
||||
struct StartUp
|
||||
{
|
||||
for (size_t i = 0; i < ctx->num_iterations(); ++i)
|
||||
StartUp()
|
||||
{
|
||||
std::ifstream input_file("benchmarks/files/jeopardy/jeopardy.json");
|
||||
nlohmann::json j;
|
||||
j << input_file;
|
||||
#ifndef __llvm__
|
||||
// pin thread to a single CPU
|
||||
cpu_set_t cpuset;
|
||||
pthread_t thread;
|
||||
thread = pthread_self();
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(std::thread::hardware_concurrency() - 1, &cpuset);
|
||||
pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuset);
|
||||
#endif
|
||||
}
|
||||
})
|
||||
};
|
||||
StartUp startup;
|
||||
|
||||
BENCHMARK("parse canada.json", [](benchpress::context* ctx)
|
||||
enum class EMode { input, output_no_indent, output_with_indent };
|
||||
|
||||
static void bench(benchpress::context& ctx,
|
||||
const std::string& in_path,
|
||||
const EMode mode)
|
||||
{
|
||||
for (size_t i = 0; i < ctx->num_iterations(); ++i)
|
||||
// using string streams for benchmarking to factor-out cold-cache disk
|
||||
// access.
|
||||
std::stringstream istr;
|
||||
{
|
||||
std::ifstream input_file("benchmarks/files/nativejson-benchmark/canada.json");
|
||||
nlohmann::json j;
|
||||
j << input_file;
|
||||
}
|
||||
})
|
||||
// read file into string stream
|
||||
std::ifstream input_file(in_path);
|
||||
istr << input_file.rdbuf();
|
||||
input_file.close();
|
||||
|
||||
BENCHMARK("parse citm_catalog.json", [](benchpress::context* ctx)
|
||||
{
|
||||
for (size_t i = 0; i < ctx->num_iterations(); ++i)
|
||||
{
|
||||
std::ifstream input_file("benchmarks/files/nativejson-benchmark/citm_catalog.json");
|
||||
nlohmann::json j;
|
||||
j << input_file;
|
||||
}
|
||||
})
|
||||
|
||||
BENCHMARK("parse twitter.json", [](benchpress::context* ctx)
|
||||
{
|
||||
for (size_t i = 0; i < ctx->num_iterations(); ++i)
|
||||
{
|
||||
std::ifstream input_file("benchmarks/files/nativejson-benchmark/twitter.json");
|
||||
nlohmann::json j;
|
||||
j << input_file;
|
||||
}
|
||||
})
|
||||
|
||||
BENCHMARK("parse numbers/floats.json", [](benchpress::context* ctx)
|
||||
{
|
||||
for (size_t i = 0; i < ctx->num_iterations(); ++i)
|
||||
{
|
||||
std::ifstream input_file("benchmarks/files/numbers/floats.json");
|
||||
nlohmann::json j;
|
||||
j << input_file;
|
||||
}
|
||||
})
|
||||
|
||||
BENCHMARK("parse numbers/signed_ints.json", [](benchpress::context* ctx)
|
||||
{
|
||||
for (size_t i = 0; i < ctx->num_iterations(); ++i)
|
||||
{
|
||||
std::ifstream input_file("benchmarks/files/numbers/signed_ints.json");
|
||||
nlohmann::json j;
|
||||
j << input_file;
|
||||
}
|
||||
})
|
||||
|
||||
BENCHMARK("parse numbers/unsigned_ints.json", [](benchpress::context* ctx)
|
||||
{
|
||||
for (size_t i = 0; i < ctx->num_iterations(); ++i)
|
||||
{
|
||||
std::ifstream input_file("benchmarks/files/numbers/unsigned_ints.json");
|
||||
nlohmann::json j;
|
||||
j << input_file;
|
||||
}
|
||||
})
|
||||
|
||||
BENCHMARK("dump jeopardy.json", [](benchpress::context* ctx)
|
||||
{
|
||||
std::ifstream input_file("benchmarks/files/jeopardy/jeopardy.json");
|
||||
nlohmann::json j;
|
||||
j << input_file;
|
||||
std::ofstream output_file("jeopardy.dump.json");
|
||||
|
||||
ctx->reset_timer();
|
||||
for (size_t i = 0; i < ctx->num_iterations(); ++i)
|
||||
{
|
||||
output_file << j;
|
||||
// read the stream once
|
||||
json j;
|
||||
j << istr;
|
||||
// clear flags and rewind
|
||||
istr.clear();
|
||||
istr.seekg(0);
|
||||
}
|
||||
|
||||
std::remove("jeopardy.dump.json");
|
||||
})
|
||||
|
||||
BENCHMARK("dump jeopardy.json with indent", [](benchpress::context* ctx)
|
||||
{
|
||||
std::ifstream input_file("benchmarks/files/jeopardy/jeopardy.json");
|
||||
nlohmann::json j;
|
||||
j << input_file;
|
||||
std::ofstream output_file("jeopardy.dump.json");
|
||||
|
||||
ctx->reset_timer();
|
||||
for (size_t i = 0; i < ctx->num_iterations(); ++i)
|
||||
switch (mode)
|
||||
{
|
||||
output_file << std::setw(4) << j;
|
||||
}
|
||||
// benchmarking input
|
||||
case EMode::input:
|
||||
{
|
||||
ctx.reset_timer();
|
||||
|
||||
std::remove("jeopardy.dump.json");
|
||||
})
|
||||
for (size_t i = 0; i < ctx.num_iterations(); ++i)
|
||||
{
|
||||
// clear flags and rewind
|
||||
istr.clear();
|
||||
istr.seekg(0);
|
||||
json j;
|
||||
j << istr;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// benchmarking output
|
||||
case EMode::output_no_indent:
|
||||
case EMode::output_with_indent:
|
||||
{
|
||||
// create JSON value from input
|
||||
json j;
|
||||
j << istr;
|
||||
std::stringstream ostr;
|
||||
|
||||
ctx.reset_timer();
|
||||
for (size_t i = 0; i < ctx.num_iterations(); ++i)
|
||||
{
|
||||
if (mode == EMode::output_no_indent)
|
||||
{
|
||||
ostr << j;
|
||||
}
|
||||
else
|
||||
{
|
||||
ostr << std::setw(4) << j;
|
||||
}
|
||||
|
||||
// reset data
|
||||
ostr.str(std::string());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define BENCHMARK_I(mode, title, in_path) \
|
||||
BENCHMARK((title), [](benchpress::context* ctx) \
|
||||
{ \
|
||||
bench(*ctx, (in_path), (mode)); \
|
||||
})
|
||||
|
||||
BENCHMARK_I(EMode::input, "parse jeopardy.json", "benchmarks/files/jeopardy/jeopardy.json");
|
||||
BENCHMARK_I(EMode::input, "parse canada.json", "benchmarks/files/nativejson-benchmark/canada.json");
|
||||
BENCHMARK_I(EMode::input, "parse citm_catalog.json", "benchmarks/files/nativejson-benchmark/citm_catalog.json");
|
||||
BENCHMARK_I(EMode::input, "parse twitter.json", "benchmarks/files/nativejson-benchmark/twitter.json");
|
||||
BENCHMARK_I(EMode::input, "parse numbers/floats.json", "benchmarks/files/numbers/floats.json");
|
||||
BENCHMARK_I(EMode::input, "parse numbers/signed_ints.json", "benchmarks/files/numbers/signed_ints.json");
|
||||
BENCHMARK_I(EMode::input, "parse numbers/unsigned_ints.json", "benchmarks/files/numbers/unsigned_ints.json");
|
||||
|
||||
BENCHMARK_I(EMode::output_no_indent, "dump jeopardy.json", "benchmarks/files/jeopardy/jeopardy.json");
|
||||
BENCHMARK_I(EMode::output_with_indent, "dump jeopardy.json with indent", "benchmarks/files/jeopardy/jeopardy.json");
|
||||
BENCHMARK_I(EMode::output_no_indent, "dump numbers/floats.json", "benchmarks/files/numbers/floats.json");
|
||||
BENCHMARK_I(EMode::output_no_indent, "dump numbers/signed_ints.json", "benchmarks/files/numbers/signed_ints.json");
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
@PACKAGE_INIT@
|
||||
set_and_check(JSON_INCLUDE_DIR "@PACKAGE_JSON_INCLUDE_DESTINATION@")
|
||||
|
||||
cmake_policy(PUSH)
|
||||
cmake_policy(SET CMP0024 OLD)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/@JSON_TARGETS_FILENAME@)
|
||||
cmake_policy(POP)
|
||||
cmake_policy(POP)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#---------------------------------------------------------------------------
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = "JSON for Modern C++"
|
||||
PROJECT_NUMBER = 2.0.2
|
||||
PROJECT_NUMBER = 2.1.0
|
||||
PROJECT_BRIEF =
|
||||
PROJECT_LOGO =
|
||||
OUTPUT_DIRECTORY = .
|
||||
@@ -109,7 +109,7 @@ RECURSIVE = NO
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXCLUDE_SYMBOLS = nlohmann::anonymous_namespace
|
||||
EXCLUDE_SYMBOLS = nlohmann::detail
|
||||
EXAMPLE_PATH = examples
|
||||
EXAMPLE_PATTERNS =
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
|
||||
@@ -57,6 +57,7 @@ doxygen: create_output create_links
|
||||
$(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, AllocatorType >@@g' html/*.html
|
||||
$(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >@@g' html/*.html
|
||||
$(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >@@g' html/*.html
|
||||
$(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >@@g' html/*.html
|
||||
|
||||
upload: clean doxygen check_output
|
||||
cd html ; ../scripts/git-update-ghpages nlohmann/json
|
||||
|
||||
@@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/p5o4znPnGHJpDVqN"><b>online</b></a>
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/4NEU6ZZMoM9lpIex"><b>online</b></a>
|
||||
@@ -8,7 +8,7 @@ int main()
|
||||
json object =
|
||||
{
|
||||
{"the good", "il buono"},
|
||||
{"the bad", "il cativo"},
|
||||
{"the bad", "il cattivo"},
|
||||
{"the ugly", "il brutto"}
|
||||
};
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/rsnwWxpDjmtRRSzb"><b>online</b></a>
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/tb5CaFfsMWpAvi7m"><b>online</b></a>
|
||||
@@ -8,7 +8,7 @@ int main()
|
||||
json object =
|
||||
{
|
||||
{"the good", "il buono"},
|
||||
{"the bad", "il cativo"},
|
||||
{"the bad", "il cattivo"},
|
||||
{"the ugly", "il brutto"}
|
||||
};
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/aeoZrnhnb3HKClCY"><b>online</b></a>
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/NFG86H5khRUePc1s"><b>online</b></a>
|
||||
@@ -1,12 +0,0 @@
|
||||
#include <json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create a JSON value with default null value
|
||||
json j;
|
||||
|
||||
// serialize the JSON null value
|
||||
std::cout << j << '\n';
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/dRptmFmhvpsYB49t"><b>online</b></a>
|
||||
@@ -1 +0,0 @@
|
||||
null
|
||||
@@ -1,58 +0,0 @@
|
||||
#include <json.hpp>
|
||||
#include <deque>
|
||||
#include <list>
|
||||
#include <forward_list>
|
||||
#include <set>
|
||||
#include <unordered_set>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create an array from std::vector
|
||||
std::vector<int> c_vector {1, 2, 3, 4};
|
||||
json j_vec(c_vector);
|
||||
|
||||
// create an array from std::deque
|
||||
std::deque<double> c_deque {1.2, 2.3, 3.4, 5.6};
|
||||
json j_deque(c_deque);
|
||||
|
||||
// create an array from std::list
|
||||
std::list<bool> c_list {true, true, false, true};
|
||||
json j_list(c_list);
|
||||
|
||||
// create an array from std::forward_list
|
||||
std::forward_list<int64_t> c_flist {12345678909876, 23456789098765, 34567890987654, 45678909876543};
|
||||
json j_flist(c_flist);
|
||||
|
||||
// create an array from std::array
|
||||
std::array<unsigned long, 4> c_array {{1, 2, 3, 4}};
|
||||
json j_array(c_array);
|
||||
|
||||
// create an array from std::set
|
||||
std::set<std::string> c_set {"one", "two", "three", "four", "one"};
|
||||
json j_set(c_set); // only one entry for "one" is used
|
||||
|
||||
// create an array from std::unordered_set
|
||||
std::unordered_set<std::string> c_uset {"one", "two", "three", "four", "one"};
|
||||
json j_uset(c_uset); // only one entry for "one" is used
|
||||
|
||||
// create an array from std::multiset
|
||||
std::multiset<std::string> c_mset {"one", "two", "one", "four"};
|
||||
json j_mset(c_mset); // only one entry for "one" is used
|
||||
|
||||
// create an array from std::unordered_multiset
|
||||
std::unordered_multiset<std::string> c_umset {"one", "two", "one", "four"};
|
||||
json j_umset(c_umset); // both entries for "one" are used
|
||||
|
||||
// serialize the JSON arrays
|
||||
std::cout << j_vec << '\n';
|
||||
std::cout << j_deque << '\n';
|
||||
std::cout << j_list << '\n';
|
||||
std::cout << j_flist << '\n';
|
||||
std::cout << j_array << '\n';
|
||||
std::cout << j_set << '\n';
|
||||
std::cout << j_uset << '\n';
|
||||
std::cout << j_mset << '\n';
|
||||
std::cout << j_umset << '\n';
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/MghSilgvyh4ZJShY"><b>online</b></a>
|
||||
@@ -1,9 +0,0 @@
|
||||
[1,2,3,4]
|
||||
[1.2,2.3,3.4,5.6]
|
||||
[true,true,false,true]
|
||||
[12345678909876,23456789098765,34567890987654,45678909876543]
|
||||
[1,2,3,4]
|
||||
["four","one","three","two"]
|
||||
["four","three","two","one"]
|
||||
["four","one","one","two"]
|
||||
["four","two","one","one"]
|
||||
@@ -1,27 +0,0 @@
|
||||
#include <json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create values of different integer types
|
||||
short n42 = 42;
|
||||
int n23 = 23;
|
||||
long n1024 = 1024;
|
||||
int_least32_t n17 = 17;
|
||||
uint8_t n8 = 8;
|
||||
|
||||
// create JSON numbers
|
||||
json j42(n42);
|
||||
json j23(n23);
|
||||
json j1024(n1024);
|
||||
json j17(n17);
|
||||
json j8(n8);
|
||||
|
||||
// serialize the JSON numbers
|
||||
std::cout << j42 << '\n';
|
||||
std::cout << j23 << '\n';
|
||||
std::cout << j1024 << '\n';
|
||||
std::cout << j17 << '\n';
|
||||
std::cout << j8 << '\n';
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/PcMzhcu2RpD7KSwr"><b>online</b></a>
|
||||
@@ -1,5 +0,0 @@
|
||||
42
|
||||
23
|
||||
1024
|
||||
17
|
||||
8
|
||||
@@ -1,21 +0,0 @@
|
||||
#include <json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create values of different floating-point types
|
||||
float f42 = 42.23;
|
||||
float f_nan = 1.0f / 0.0f;
|
||||
double f23 = 23.42;
|
||||
|
||||
// create JSON numbers
|
||||
json j42(f42);
|
||||
json j_nan(f_nan);
|
||||
json j23(f23);
|
||||
|
||||
// serialize the JSON numbers
|
||||
std::cout << j42 << '\n';
|
||||
std::cout << j_nan << '\n';
|
||||
std::cout << j23 << '\n';
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/2TCYWSrOxnR05AZI"><b>online</b></a>
|
||||
@@ -1,3 +0,0 @@
|
||||
42.2299995422363
|
||||
null
|
||||
23.42
|
||||
@@ -1,41 +0,0 @@
|
||||
#include <json.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create an object from std::map
|
||||
std::map<std::string, int> c_map
|
||||
{
|
||||
{"one", 1}, {"two", 2}, {"three", 3}
|
||||
};
|
||||
json j_map(c_map);
|
||||
|
||||
// create an object from std::unordered_map
|
||||
std::unordered_map<const char*, double> c_umap
|
||||
{
|
||||
{"one", 1.2}, {"two", 2.3}, {"three", 3.4}
|
||||
};
|
||||
json j_umap(c_umap);
|
||||
|
||||
// create an object from std::multimap
|
||||
std::multimap<std::string, bool> c_mmap
|
||||
{
|
||||
{"one", true}, {"two", true}, {"three", false}, {"three", true}
|
||||
};
|
||||
json j_mmap(c_mmap); // only one entry for key "three" is used
|
||||
|
||||
// create an object from std::unordered_multimap
|
||||
std::unordered_multimap<std::string, bool> c_ummap
|
||||
{
|
||||
{"one", true}, {"two", true}, {"three", false}, {"three", true}
|
||||
};
|
||||
json j_ummap(c_ummap); // only one entry for key "three" is used
|
||||
|
||||
// serialize the JSON objects
|
||||
std::cout << j_map << '\n';
|
||||
std::cout << j_umap << '\n';
|
||||
std::cout << j_mmap << '\n';
|
||||
std::cout << j_ummap << '\n';
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/JzLCMcSXNsh4uVWa"><b>online</b></a>
|
||||
@@ -1,4 +0,0 @@
|
||||
{"one":1,"three":3,"two":2}
|
||||
{"one":1.2,"three":3.4,"two":2.3}
|
||||
{"one":true,"three":false,"two":true}
|
||||
{"one":true,"three":false,"two":true}
|
||||
@@ -1,15 +0,0 @@
|
||||
#include <json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create a string value
|
||||
std::string s = "The quick brown fox jumps over the lazy dog.";
|
||||
|
||||
// create a JSON string value
|
||||
json j = s;
|
||||
|
||||
// serialize the JSON string
|
||||
std::cout << j << '\n';
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/b9hbCY8zfOiTOuoK"><b>online</b></a>
|
||||
@@ -1 +0,0 @@
|
||||
"The quick brown fox jumps over the lazy dog."
|
||||
211
doc/examples/basic_json__CompatibleType.cpp
Normal file
211
doc/examples/basic_json__CompatibleType.cpp
Normal file
@@ -0,0 +1,211 @@
|
||||
#include <json.hpp>
|
||||
#include <deque>
|
||||
#include <list>
|
||||
#include <forward_list>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// ============
|
||||
// object types
|
||||
// ============
|
||||
|
||||
// create an object from an object_t value
|
||||
json::object_t object_value = { {"one", 1}, {"two", 2} };
|
||||
json j_object_t(object_value);
|
||||
|
||||
// create an object from std::map
|
||||
std::map<std::string, int> c_map
|
||||
{
|
||||
{"one", 1}, {"two", 2}, {"three", 3}
|
||||
};
|
||||
json j_map(c_map);
|
||||
|
||||
// create an object from std::unordered_map
|
||||
std::unordered_map<const char*, double> c_umap
|
||||
{
|
||||
{"one", 1.2}, {"two", 2.3}, {"three", 3.4}
|
||||
};
|
||||
json j_umap(c_umap);
|
||||
|
||||
// create an object from std::multimap
|
||||
std::multimap<std::string, bool> c_mmap
|
||||
{
|
||||
{"one", true}, {"two", true}, {"three", false}, {"three", true}
|
||||
};
|
||||
json j_mmap(c_mmap); // only one entry for key "three" is used
|
||||
|
||||
// create an object from std::unordered_multimap
|
||||
std::unordered_multimap<std::string, bool> c_ummap
|
||||
{
|
||||
{"one", true}, {"two", true}, {"three", false}, {"three", true}
|
||||
};
|
||||
json j_ummap(c_ummap); // only one entry for key "three" is used
|
||||
|
||||
// serialize the JSON objects
|
||||
std::cout << j_object_t << '\n';
|
||||
std::cout << j_map << '\n';
|
||||
std::cout << j_umap << '\n';
|
||||
std::cout << j_mmap << '\n';
|
||||
std::cout << j_ummap << "\n\n";
|
||||
|
||||
|
||||
// ===========
|
||||
// array types
|
||||
// ===========
|
||||
|
||||
// create an array from an array_t value
|
||||
json::array_t array_value = {"one", "two", 3, 4.5, false};
|
||||
json j_array_t(array_value);
|
||||
|
||||
// create an array from std::vector
|
||||
std::vector<int> c_vector {1, 2, 3, 4};
|
||||
json j_vec(c_vector);
|
||||
|
||||
// create an array from std::deque
|
||||
std::deque<double> c_deque {1.2, 2.3, 3.4, 5.6};
|
||||
json j_deque(c_deque);
|
||||
|
||||
// create an array from std::list
|
||||
std::list<bool> c_list {true, true, false, true};
|
||||
json j_list(c_list);
|
||||
|
||||
// create an array from std::forward_list
|
||||
std::forward_list<int64_t> c_flist {12345678909876, 23456789098765, 34567890987654, 45678909876543};
|
||||
json j_flist(c_flist);
|
||||
|
||||
// create an array from std::array
|
||||
std::array<unsigned long, 4> c_array {{1, 2, 3, 4}};
|
||||
json j_array(c_array);
|
||||
|
||||
// create an array from std::set
|
||||
std::set<std::string> c_set {"one", "two", "three", "four", "one"};
|
||||
json j_set(c_set); // only one entry for "one" is used
|
||||
|
||||
// create an array from std::unordered_set
|
||||
std::unordered_set<std::string> c_uset {"one", "two", "three", "four", "one"};
|
||||
json j_uset(c_uset); // only one entry for "one" is used
|
||||
|
||||
// create an array from std::multiset
|
||||
std::multiset<std::string> c_mset {"one", "two", "one", "four"};
|
||||
json j_mset(c_mset); // both entries for "one" are used
|
||||
|
||||
// create an array from std::unordered_multiset
|
||||
std::unordered_multiset<std::string> c_umset {"one", "two", "one", "four"};
|
||||
json j_umset(c_umset); // both entries for "one" are used
|
||||
|
||||
// serialize the JSON arrays
|
||||
std::cout << j_array_t << '\n';
|
||||
std::cout << j_vec << '\n';
|
||||
std::cout << j_deque << '\n';
|
||||
std::cout << j_list << '\n';
|
||||
std::cout << j_flist << '\n';
|
||||
std::cout << j_array << '\n';
|
||||
std::cout << j_set << '\n';
|
||||
std::cout << j_uset << '\n';
|
||||
std::cout << j_mset << '\n';
|
||||
std::cout << j_umset << "\n\n";
|
||||
|
||||
|
||||
// ============
|
||||
// string types
|
||||
// ============
|
||||
|
||||
// create string from a string_t value
|
||||
json::string_t string_value = "The quick brown fox jumps over the lazy dog.";
|
||||
json j_string_t(string_value);
|
||||
|
||||
// create a JSON string directly from a string literal
|
||||
json j_string_literal("The quick brown fox jumps over the lazy dog.");
|
||||
|
||||
// create string from std::string
|
||||
std::string s_stdstring = "The quick brown fox jumps over the lazy dog.";
|
||||
json j_stdstring(s_stdstring);
|
||||
|
||||
// serialize the JSON strings
|
||||
std::cout << j_string_t << '\n';
|
||||
std::cout << j_string_literal << '\n';
|
||||
std::cout << j_stdstring << "\n\n";
|
||||
|
||||
|
||||
// ============
|
||||
// number types
|
||||
// ============
|
||||
|
||||
// create a JSON number from number_integer_t
|
||||
json::number_integer_t value_integer_t = -42;
|
||||
json j_integer_t(value_integer_t);
|
||||
|
||||
// create a JSON number from number_unsigned_t
|
||||
json::number_integer_t value_unsigned_t = 17;
|
||||
json j_unsigned_t(value_unsigned_t);
|
||||
|
||||
// create a JSON number from an anonymous enum
|
||||
enum { enum_value = 17 };
|
||||
json j_enum(enum_value);
|
||||
|
||||
// create values of different integer types
|
||||
short n_short = 42;
|
||||
int n_int = -23;
|
||||
long n_long = 1024;
|
||||
int_least32_t n_int_least32_t = -17;
|
||||
uint8_t n_uint8_t = 8;
|
||||
|
||||
// create (integer) JSON numbers
|
||||
json j_short(n_short);
|
||||
json j_int(n_int);
|
||||
json j_long(n_long);
|
||||
json j_int_least32_t(n_int_least32_t);
|
||||
json j_uint8_t(n_uint8_t);
|
||||
|
||||
// create values of different floating-point types
|
||||
json::number_float_t v_ok = 3.141592653589793;
|
||||
json::number_float_t v_nan = NAN;
|
||||
json::number_float_t v_infinity = INFINITY;
|
||||
|
||||
// create values of different floating-point types
|
||||
float n_float = 42.23;
|
||||
float n_float_nan = 1.0f / 0.0f;
|
||||
double n_double = 23.42;
|
||||
|
||||
// create (floating point) JSON numbers
|
||||
json j_ok(v_ok);
|
||||
json j_nan(v_nan);
|
||||
json j_infinity(v_infinity);
|
||||
json j_float(n_float);
|
||||
json j_float_nan(n_float_nan);
|
||||
json j_double(n_double);
|
||||
|
||||
// serialize the JSON numbers
|
||||
std::cout << j_integer_t << '\n';
|
||||
std::cout << j_unsigned_t << '\n';
|
||||
std::cout << j_enum << '\n';
|
||||
std::cout << j_short << '\n';
|
||||
std::cout << j_int << '\n';
|
||||
std::cout << j_long << '\n';
|
||||
std::cout << j_int_least32_t << '\n';
|
||||
std::cout << j_uint8_t << '\n';
|
||||
std::cout << j_ok << '\n';
|
||||
std::cout << j_nan << '\n';
|
||||
std::cout << j_infinity << '\n';
|
||||
std::cout << j_float << '\n';
|
||||
std::cout << j_float_nan << '\n';
|
||||
std::cout << j_double << "\n\n";
|
||||
|
||||
|
||||
// =============
|
||||
// boolean types
|
||||
// =============
|
||||
|
||||
// create boolean values
|
||||
json j_truth = true;
|
||||
json j_falsity = false;
|
||||
|
||||
// serialize the JSON booleans
|
||||
std::cout << j_truth << '\n';
|
||||
std::cout << j_falsity << '\n';
|
||||
}
|
||||
1
doc/examples/basic_json__CompatibleType.link
Normal file
1
doc/examples/basic_json__CompatibleType.link
Normal file
@@ -0,0 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/VM7W2kpE7sIYJ5DW"><b>online</b></a>
|
||||
38
doc/examples/basic_json__CompatibleType.output
Normal file
38
doc/examples/basic_json__CompatibleType.output
Normal file
@@ -0,0 +1,38 @@
|
||||
{"one":1,"two":2}
|
||||
{"one":1,"three":3,"two":2}
|
||||
{"one":1.2,"three":3.4,"two":2.3}
|
||||
{"one":true,"three":false,"two":true}
|
||||
{"one":true,"three":false,"two":true}
|
||||
|
||||
["one","two",3,4.5,false]
|
||||
[1,2,3,4]
|
||||
[1.2,2.3,3.4,5.6]
|
||||
[true,true,false,true]
|
||||
[12345678909876,23456789098765,34567890987654,45678909876543]
|
||||
[1,2,3,4]
|
||||
["four","one","three","two"]
|
||||
["four","three","two","one"]
|
||||
["four","one","one","two"]
|
||||
["four","two","one","one"]
|
||||
|
||||
"The quick brown fox jumps over the lazy dog."
|
||||
"The quick brown fox jumps over the lazy dog."
|
||||
"The quick brown fox jumps over the lazy dog."
|
||||
|
||||
-42
|
||||
17
|
||||
17
|
||||
42
|
||||
-23
|
||||
1024
|
||||
-17
|
||||
8
|
||||
3.14159265358979
|
||||
null
|
||||
null
|
||||
42.2299995422363
|
||||
null
|
||||
23.42
|
||||
|
||||
true
|
||||
false
|
||||
@@ -1,15 +0,0 @@
|
||||
#include <json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create an array_t value
|
||||
json::array_t value = {"one", "two", 3, 4.5, false};
|
||||
|
||||
// create a JSON array from the value
|
||||
json j(value);
|
||||
|
||||
// serialize the JSON array
|
||||
std::cout << j << '\n';
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/dTbSNAvl6TqrMEAn"><b>online</b></a>
|
||||
@@ -1 +0,0 @@
|
||||
["one","two",3,4.5,false]
|
||||
@@ -1,14 +0,0 @@
|
||||
#include <json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create boolean values
|
||||
json j_truth = true;
|
||||
json j_falsity = false;
|
||||
|
||||
// serialize the JSON booleans
|
||||
std::cout << j_truth << '\n';
|
||||
std::cout << j_falsity << '\n';
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/VmVl9pyrQp8LyOnU"><b>online</b></a>
|
||||
@@ -1,2 +0,0 @@
|
||||
true
|
||||
false
|
||||
@@ -1,15 +0,0 @@
|
||||
#include <json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// an anonymous enum
|
||||
enum { t = 17 };
|
||||
|
||||
// create a JSON number from the enum
|
||||
json j(t);
|
||||
|
||||
// serialize the JSON numbers
|
||||
std::cout << j << '\n';
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/3xQ1qy7BT9OrSSCo"><b>online</b></a>
|
||||
@@ -1 +0,0 @@
|
||||
17
|
||||
@@ -27,7 +27,8 @@ int main()
|
||||
ss << text;
|
||||
|
||||
// create JSON from stream
|
||||
json j_complete(ss);
|
||||
json j_complete(ss); // deprecated!
|
||||
// shall be replaced by: json j_complete = json::parse(ss);
|
||||
std::cout << std::setw(4) << j_complete << "\n\n";
|
||||
|
||||
|
||||
@@ -51,5 +52,6 @@ int main()
|
||||
|
||||
// create JSON from stream (with callback)
|
||||
json j_filtered(ss, cb);
|
||||
// shall be replaced by: json j_filtered = json::parse(ss, cb);
|
||||
std::cout << std::setw(4) << j_filtered << '\n';
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/VzSqLszbnoWE92dD"><b>online</b></a>
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/R6dzpKXlxrttShf7"><b>online</b></a>
|
||||
@@ -4,9 +4,12 @@ using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create a JSON null value
|
||||
json j(nullptr);
|
||||
// implicitly create a JSON null value
|
||||
json j1;
|
||||
|
||||
// explicitly create a JSON null value
|
||||
json j2(nullptr);
|
||||
|
||||
// serialize the JSON null value
|
||||
std::cout << j << '\n';
|
||||
std::cout << j1 << '\n' << j2 << '\n';
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/PMMpoM0ujdJDsuta"><b>online</b></a>
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/9Tvfs2dJBW8m8ihA"><b>online</b></a>
|
||||
@@ -1 +1,2 @@
|
||||
null
|
||||
null
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#include <json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create values of different floating-point types
|
||||
json::number_float_t v_ok = 3.141592653589793;
|
||||
json::number_float_t v_nan = NAN;
|
||||
json::number_float_t v_infinity = INFINITY;
|
||||
|
||||
// create JSON numbers
|
||||
json j_ok(v_ok);
|
||||
json j_nan(v_nan);
|
||||
json j_infinity(v_infinity);
|
||||
|
||||
// serialize the JSON numbers
|
||||
std::cout << j_ok << '\n';
|
||||
std::cout << j_nan << '\n';
|
||||
std::cout << j_infinity << '\n';
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/OTgOxjIAKFvxpFdm"><b>online</b></a>
|
||||
@@ -1,3 +0,0 @@
|
||||
3.14159265358979
|
||||
null
|
||||
null
|
||||
@@ -1,14 +0,0 @@
|
||||
#include <json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create a JSON number from number_integer_t
|
||||
json::number_integer_t value = 42;
|
||||
|
||||
json j(value);
|
||||
|
||||
// serialize the JSON numbers
|
||||
std::cout << j << '\n';
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/cCQRCvjXdRM9YpT5"><b>online</b></a>
|
||||
@@ -1 +0,0 @@
|
||||
42
|
||||
@@ -1,15 +0,0 @@
|
||||
#include <json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create an object_t value
|
||||
json::object_t value = { {"one", 1}, {"two", 2} };
|
||||
|
||||
// create a JSON object from the value
|
||||
json j(value);
|
||||
|
||||
// serialize the JSON object
|
||||
std::cout << j << '\n';
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/DgtHcz5L6JphTOGJ"><b>online</b></a>
|
||||
@@ -1 +0,0 @@
|
||||
{"one":1,"two":2}
|
||||
@@ -1,15 +0,0 @@
|
||||
#include <json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create an string_t value
|
||||
json::string_t value = "The quick brown fox jumps over the lazy doc";
|
||||
|
||||
// create a JSON string from the value
|
||||
json j(value);
|
||||
|
||||
// serialize the JSON array
|
||||
std::cout << j << '\n';
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/cwNYP1q2mT8CFLTk"><b>online</b></a>
|
||||
@@ -1 +0,0 @@
|
||||
"The quick brown fox jumps over the lazy doc"
|
||||
@@ -1,12 +0,0 @@
|
||||
#include <json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create a JSON string directly from a string literal
|
||||
json j("The quick brown fox jumps over the lazy doc");
|
||||
|
||||
// serialize the JSON array
|
||||
std::cout << j << '\n';
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/AtV4zVErfLwkileg"><b>online</b></a>
|
||||
@@ -1 +0,0 @@
|
||||
"The quick brown fox jumps over the lazy doc"
|
||||
30
doc/examples/emplace.cpp
Normal file
30
doc/examples/emplace.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json object = {{"one", 1}, {"two", 2}};
|
||||
json null;
|
||||
|
||||
// print values
|
||||
std::cout << object << '\n';
|
||||
std::cout << null << '\n';
|
||||
|
||||
// add values
|
||||
auto res1 = object.emplace("three", 3);
|
||||
null.emplace("A", "a");
|
||||
null.emplace("B", "b");
|
||||
|
||||
// the following call will not add an object, because there is already
|
||||
// a value stored at key "B"
|
||||
auto res2 = null.emplace("B", "c");
|
||||
|
||||
// print values
|
||||
std::cout << object << '\n';
|
||||
std::cout << *res1.first << " " << std::boolalpha << res1.second << '\n';
|
||||
|
||||
std::cout << null << '\n';
|
||||
std::cout << *res2.first << " " << std::boolalpha << res2.second << '\n';
|
||||
}
|
||||
1
doc/examples/emplace.link
Normal file
1
doc/examples/emplace.link
Normal file
@@ -0,0 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/B6ILaoysGMliouEO"><b>online</b></a>
|
||||
6
doc/examples/emplace.output
Normal file
6
doc/examples/emplace.output
Normal file
@@ -0,0 +1,6 @@
|
||||
{"one":1,"two":2}
|
||||
null
|
||||
{"one":1,"three":3,"two":2}
|
||||
3 true
|
||||
{"A":"a","B":"b"}
|
||||
"b" false
|
||||
23
doc/examples/emplace_back.cpp
Normal file
23
doc/examples/emplace_back.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create JSON values
|
||||
json array = {1, 2, 3, 4, 5};
|
||||
json null;
|
||||
|
||||
// print values
|
||||
std::cout << array << '\n';
|
||||
std::cout << null << '\n';
|
||||
|
||||
// add values
|
||||
array.emplace_back(6);
|
||||
null.emplace_back("first");
|
||||
null.emplace_back(3, "second");
|
||||
|
||||
// print values
|
||||
std::cout << array << '\n';
|
||||
std::cout << null << '\n';
|
||||
}
|
||||
1
doc/examples/emplace_back.link
Normal file
1
doc/examples/emplace_back.link
Normal file
@@ -0,0 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/jdch45YEMX94DvlH"><b>online</b></a>
|
||||
4
doc/examples/emplace_back.output
Normal file
4
doc/examples/emplace_back.output
Normal file
@@ -0,0 +1,4 @@
|
||||
[1,2,3,4,5]
|
||||
null
|
||||
[1,2,3,4,5,6]
|
||||
["first",["second","second","second"]]
|
||||
18
doc/examples/from_cbor.cpp
Normal file
18
doc/examples/from_cbor.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create byte vector
|
||||
std::vector<uint8_t> v = {0xa2, 0x67, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63,
|
||||
0x74, 0xf5, 0x66, 0x73, 0x63, 0x68, 0x65, 0x6d,
|
||||
0x61, 0x00
|
||||
};
|
||||
|
||||
// deserialize it with CBOR
|
||||
json j = json::from_cbor(v);
|
||||
|
||||
// print the deserialized JSON value
|
||||
std::cout << std::setw(2) << j << std::endl;
|
||||
}
|
||||
1
doc/examples/from_cbor.link
Normal file
1
doc/examples/from_cbor.link
Normal file
@@ -0,0 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/TDPaxmQ7PsvfWxrs"><b>online</b></a>
|
||||
4
doc/examples/from_cbor.output
Normal file
4
doc/examples/from_cbor.output
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"compact": true,
|
||||
"schema": 0
|
||||
}
|
||||
18
doc/examples/from_msgpack.cpp
Normal file
18
doc/examples/from_msgpack.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create byte vector
|
||||
std::vector<uint8_t> v = {0x82, 0xa7, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63,
|
||||
0x74, 0xc3, 0xa6, 0x73, 0x63, 0x68, 0x65, 0x6d,
|
||||
0x61, 0x00
|
||||
};
|
||||
|
||||
// deserialize it with MessagePack
|
||||
json j = json::from_msgpack(v);
|
||||
|
||||
// print the deserialized JSON value
|
||||
std::cout << std::setw(2) << j << std::endl;
|
||||
}
|
||||
1
doc/examples/from_msgpack.link
Normal file
1
doc/examples/from_msgpack.link
Normal file
@@ -0,0 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/7vRGmLdVcYM7POhE"><b>online</b></a>
|
||||
4
doc/examples/from_msgpack.output
Normal file
4
doc/examples/from_msgpack.output
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"compact": true,
|
||||
"schema": 0
|
||||
}
|
||||
9
doc/examples/meta.cpp
Normal file
9
doc/examples/meta.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// call meta()
|
||||
std::cout << std::setw(4) << json::meta() << '\n';
|
||||
}
|
||||
1
doc/examples/meta.link
Normal file
1
doc/examples/meta.link
Normal file
@@ -0,0 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/3hERJociqLo3vdod"><b>online</b></a>
|
||||
17
doc/examples/meta.output
Normal file
17
doc/examples/meta.output
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"compiler": {
|
||||
"c++": "201103",
|
||||
"family": "clang",
|
||||
"version": "8.0.0 (clang-800.0.42.1)"
|
||||
},
|
||||
"copyright": "(C) 2013-2017 Niels Lohmann",
|
||||
"name": "JSON for Modern C++",
|
||||
"platform": "apple",
|
||||
"url": "https://github.com/nlohmann/json",
|
||||
"version": {
|
||||
"major": 2,
|
||||
"minor": 1,
|
||||
"patch": 0,
|
||||
"string": "2.1.0"
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ int main()
|
||||
// output the changed array
|
||||
std::cout << j["array"] << '\n';
|
||||
|
||||
// "change" the arry element past the end
|
||||
// "change" the array element past the end
|
||||
j["/array/-"_json_pointer] = 55;
|
||||
// output the changed array
|
||||
std::cout << j["array"] << '\n';
|
||||
|
||||
@@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/xzFX3E4gYBXFwd04"><b>online</b></a>
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/AYgVTzCodPApT4hT"><b>online</b></a>
|
||||
28
doc/examples/parse__array__parser_callback_t.cpp
Normal file
28
doc/examples/parse__array__parser_callback_t.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#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";
|
||||
}
|
||||
1
doc/examples/parse__array__parser_callback_t.link
Normal file
1
doc/examples/parse__array__parser_callback_t.link
Normal file
@@ -0,0 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/CwZnqGqte14SYJ5s"><b>online</b></a>
|
||||
20
doc/examples/parse__array__parser_callback_t.output
Normal file
20
doc/examples/parse__array__parser_callback_t.output
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#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";
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/F8VaVFyys87qQRt5"><b>online</b></a>
|
||||
@@ -0,0 +1,6 @@
|
||||
[
|
||||
1,
|
||||
2,
|
||||
3
|
||||
]
|
||||
|
||||
13
doc/examples/parse__iteratortype__parser_callback_t.cpp
Normal file
13
doc/examples/parse__iteratortype__parser_callback_t.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#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";
|
||||
}
|
||||
1
doc/examples/parse__iteratortype__parser_callback_t.link
Normal file
1
doc/examples/parse__iteratortype__parser_callback_t.link
Normal file
@@ -0,0 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/ojh4Eeol4G9RgeRV"><b>online</b></a>
|
||||
@@ -0,0 +1,6 @@
|
||||
[
|
||||
1,
|
||||
2,
|
||||
3
|
||||
]
|
||||
|
||||
@@ -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';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/SrKpkE9ivmvd2OUy"><b>online</b></a>
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/n888UNQlMFduURhE"><b>online</b></a>
|
||||
19
doc/examples/to_cbor.cpp
Normal file
19
doc/examples/to_cbor.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create a JSON value
|
||||
json j = R"({"compact": true, "schema": 0})"_json;
|
||||
|
||||
// serialize it to CBOR
|
||||
std::vector<uint8_t> v = json::to_cbor(j);
|
||||
|
||||
// print the vector content
|
||||
for (auto& byte : v)
|
||||
{
|
||||
std::cout << "0x" << std::hex << std::setw(2) << std::setfill('0') << (int)byte << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
1
doc/examples/to_cbor.link
Normal file
1
doc/examples/to_cbor.link
Normal file
@@ -0,0 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/UaDbrgZ8OPWaShY8"><b>online</b></a>
|
||||
1
doc/examples/to_cbor.output
Normal file
1
doc/examples/to_cbor.output
Normal file
@@ -0,0 +1 @@
|
||||
0xa2 0x67 0x63 0x6f 0x6d 0x70 0x61 0x63 0x74 0xf5 0x66 0x73 0x63 0x68 0x65 0x6d 0x61 0x00
|
||||
19
doc/examples/to_msgpack.cpp
Normal file
19
doc/examples/to_msgpack.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create a JSON value
|
||||
json j = R"({"compact": true, "schema": 0})"_json;
|
||||
|
||||
// serialize it to MessagePack
|
||||
std::vector<uint8_t> v = json::to_msgpack(j);
|
||||
|
||||
// print the vector content
|
||||
for (auto& byte : v)
|
||||
{
|
||||
std::cout << "0x" << std::hex << std::setw(2) << std::setfill('0') << (int)byte << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user