Compare commits

...

371 Commits

Author SHA1 Message Date
Niels
9e67dc46fa Merge branch 'release/v2.0.2' into develop 2016-07-31 13:37:49 +02:00
Niels
a05df038cd prepared release 2016-07-31 13:37:04 +02:00
Niels
9e51c9041e replaced individual assertions by a class invariant function 2016-07-30 18:02:41 +02:00
Niels
891918a30f cleanup and documentation 2016-07-30 16:12:10 +02:00
Niels
5405ae8601 added default value 2016-07-30 10:50:53 +02:00
Niels
b145e0c404 more cleanup 2016-07-29 23:47:16 +02:00
Niels
b2b68a0fa1 header + cleanup 2016-07-29 22:24:47 +02:00
Niels
161c74a92e some cleanup 2016-07-28 21:19:56 +02:00
Niels
6297631e22 reverted breaking changes 2016-07-27 21:40:15 +02:00
Niels
a7f8c47f68 cleaned up code
- removed unnecessary assertions
- simplified simple if/return patterns
2016-07-27 21:29:55 +02:00
Niels
bdaade91f5 fixed some errors in the README gif 2016-07-27 17:07:00 +02:00
Niels
5e88c6f254 more on travis 2016-07-25 23:41:16 +02:00
Niels
cc8102f0c4 used the wrong variable 2016-07-25 22:19:49 +02:00
Niels
fd7c7be851 fixed bash errors 2016-07-25 19:38:51 +02:00
Niels
148fed1e63 minor change 2016-07-25 18:06:59 +02:00
Niels
02fc3cddee test homebrew on OSX 2016-07-25 16:48:26 +02:00
Niels
a01ec918ac minor changes 2016-07-25 16:21:15 +02:00
Niels
d08e013dd0 improved documentation 2016-07-25 16:06:13 +02:00
Niels
369671f028 added more Unicode tests 2016-07-25 16:05:58 +02:00
Niels
dcea3a283c Merge branch 'feature/issue283' into develop (fixes #278) 2016-07-24 11:16:47 +02:00
Niels
84673b7de3 added test case from issue #283 2016-07-24 11:08:39 +02:00
Niels
e2aa2d2189 improved test coverage 2016-07-24 11:01:47 +02:00
Niels
75dbbc55cf started to implement #283 2016-07-23 09:59:09 +02:00
Niels
ddfe86cc49 fixed a bug that was found in the discussion of #274 2016-07-22 21:40:58 +02:00
Niels
51a3829680 reverted change to constexpr get_ref (does not work with GCC and MSVC) 2016-07-22 15:53:38 +02:00
Niels
4e7501e59a minor changes
- fixed a bug that did not discard strings with control characters
between 0x10 and 0x1f
- added termination proofs for two important loops
- made get_ref() constexpr
2016-07-22 15:34:45 +02:00
Niels
4c98c971b8 added benchmarks for numbers 2016-07-20 23:06:45 +02:00
Niels
1286d35767 make sure precision is reset on output streams during serialization 2016-07-20 20:07:45 +02:00
Niels
cb145cfe71 updated Changelog 2016-07-19 22:43:56 +02:00
Niels
0f834056bb removed unused header 2016-07-19 22:17:43 +02:00
Niels
2478be807c avoid recursion in the scanner 2016-07-19 22:10:27 +02:00
Niels
b64367e2f7 fix for #279 2016-07-18 16:22:10 +02:00
Niels
7f4dd5d608 added header for int64_t and uint64_t (fixes #282) 2016-07-15 19:44:19 +02:00
Niels
8116413106 Merge pull request #279 from murinicanor/patch-1
let the makefile choose the correct sed
2016-07-10 00:32:32 +02:00
Muri Nicanor
01f9ee5fd7 let the makefile choose the correct sed 2016-07-09 20:02:41 +02:00
Niels
98d48ef0c2 fixed indentation 2016-07-04 00:04:22 +02:00
Niels
71d20db4fc Merge branch 'feature/improved_documentation' into develop
- improved documentation
2016-07-01 18:02:37 +02:00
Niels
c6d45c30d5 Merge branch 'feature/parser_performance' into develop
- improved parser performance by avoiding a copy of the result value
2016-07-01 17:44:27 +02:00
Niels
8f9f561742 Merge branch 'feature/detect_unsupported_compilers' into develop
- added error macros to exclude unsupported compilers
2016-07-01 17:42:36 +02:00
Niels
513fac589b Merge branch 'feature/algorithm_loops' into develop
- replaces some raw loops by std algorithms
- used std::advance where possible
2016-07-01 17:39:25 +02:00
Niels
bd7cd330cd fixed type_name() signature 2016-07-01 17:26:09 +02:00
Niels
28644bada0 removed std::out output from test cases 2016-07-01 17:25:56 +02:00
Niels
05ddfaf5cf Merge branch 'develop' into feature/improved_documentation 2016-07-01 17:01:02 +02:00
Niels
6e1347e68c fixes #270 2016-07-01 16:58:50 +02:00
Niels
26cab42c38 some minor improvements 2016-07-01 16:52:05 +02:00
Niels
814fb31d64 Merge pull request #275 from dtoma/develop
Update hexify to use array lookup instead of ternary (#270)
2016-07-01 16:51:35 +02:00
Niels
a5262c18e2 replaced a copy by a move to increase performance by 16-25% 2016-06-30 12:43:06 +02:00
dtoma
5c129c8981 Update hexify to use array lookup instead of ternary (#270) 2016-06-29 19:28:56 +08:00
Niels
52cbda8048 using std::advance where possible 2016-06-29 12:47:29 +02:00
Niels
a0609b2da3 fixed coverage bug 2016-06-29 09:53:48 +02:00
Niels
924f78119b math... 2016-06-29 09:34:14 +02:00
Niels
7cb8ee42d5 wrong GCC version 2016-06-29 09:22:28 +02:00
Niels
d456dec320 overlapping defines 2016-06-29 09:16:18 +02:00
Niels
fc7f4b8fba replace some raw loops with algorithms 2016-06-28 22:49:05 +02:00
Niels
dc479b3f9d check for unsupported compilers 2016-06-28 22:09:22 +02:00
Niels
7ffa07e3a3 update of ChangeLog 2016-06-28 21:46:53 +02:00
Niels
d2475f9010 bumped version number 2016-06-28 21:44:03 +02:00
Niels
3d4c79922e Merge branch 'release/2.0.1' into develop 2016-06-28 21:38:59 +02:00
Niels
026fe8041d adjusted Changelog 2016-06-28 21:33:34 +02:00
Niels
a73bda8147 fixed performance regression #272 2016-06-28 21:24:18 +02:00
Niels
6a108bb84b Merge branch 'feature/issue272' into develop 2016-06-28 21:19:36 +02:00
Niels
7214243d89 reset locale (for #272) 2016-06-28 19:18:23 +02:00
Niels
420659f187 addressing #272 2016-06-28 10:42:17 +02:00
Niels
360f0f3791 updated README and ChangeLog 2016-06-24 17:39:03 +02:00
Niels
c74b9ff4f7 another fix for the MSVC version 2016-06-24 17:15:54 +02:00
Niels
a61231ad29 Merge pull request #271 from thelostt/patch-1
fixed a tiny typo
2016-06-24 11:28:01 +02:00
Mário Feroldi
6aad67af23 fixed a tiny typo 2016-06-24 05:47:00 -03:00
Niels
0767290c26 off-by-one error in the documentation 2016-06-24 08:06:41 +02:00
Niels
ca2bbdb15b clarified MSV version 2016-06-24 07:39:08 +02:00
Niels
1c719561b0 update of documentation links 2016-06-24 00:14:27 +02:00
Niels
b3cf45c8f5 updated release information 2016-06-23 23:34:41 +02:00
Niels
6542ae5766 fixed re2c warnings 2016-06-23 22:49:48 +02:00
Niels
39a9cfcc12 updated README 2016-06-23 18:08:20 +02:00
Niels
f86fe57c18 Merge branch 'feature/undo-number-roundtrip' into develop 2016-06-23 18:00:06 +02:00
Niels
04a80a8f60 Merge branch 'develop' into feature/undo-number-roundtrip 2016-06-23 05:57:41 +02:00
Niels
3497fab3b5 cleanup 2016-06-23 05:55:48 +02:00
Niels
d14366c33e Merge branch 'feature/issue269' into develop 2016-06-23 00:05:01 +02:00
Niels
7cff6c8771 Merge branch 'develop' into feature/issue269
# Conflicts:
#	README.md
2016-06-23 00:04:55 +02:00
Niels
6f76c9237b overworked ChangeLog and README 2016-06-22 22:20:55 +02:00
Niels
ecf84dddb1 test case for #269 2016-06-22 20:40:15 +02:00
Niels
59e67e768f fix for previous commit 2016-06-22 20:09:06 +02:00
Niels
3f97a5d5ad a conceptual quick fix for #269 2016-06-22 20:05:44 +02:00
Niels
15a314abea updated README 2016-06-19 22:38:54 +02:00
Niels
0865ec87d4 re-added GCC6 2016-06-19 22:20:02 +02:00
Niels
3fe654e827 fix for coverity 2016-06-19 22:12:56 +02:00
Niels
20e4b20528 fix SSL issue with coverity 2016-06-19 21:57:32 +02:00
Niels
90b46868b5 Merge branch 'develop' into feature/undo-number-roundtrip 2016-06-19 18:27:07 +02:00
Niels
8c48ef1f73 updated to Catch v1.5.6 2016-06-19 18:25:43 +02:00
Niels
b47fdf88ee Merge branch 'develop' into feature/undo-number-roundtrip 2016-06-19 17:59:53 +02:00
Niels
4ff27b207e fixed two typos 2016-06-19 17:56:58 +02:00
Niels
ad7a419a03 removed roundtripping of floats (#230) 2016-06-19 17:13:13 +02:00
Niels
4e31a0e852 minor doc changes 2016-06-19 16:17:53 +02:00
Niels
039565b9f5 trying codecov 2016-06-18 14:33:29 +02:00
Niels
bb8c7b1f45 mentioning Homebrew's --HEAD parameter 2016-06-15 21:28:27 +02:00
Niels
1eced269e3 update after PR #266 2016-06-14 15:27:21 +02:00
Niels
9eb86e1e12 Merge pull request #266 from 06needhamt/Issue
Fix Issue #265
2016-06-14 15:24:49 +02:00
Tom Needham
fb90388af5 Fix Issue #265 2016-06-14 09:59:50 +01:00
Niels
39213bf34e Merge branch 'feature/issue260' into develop 2016-06-14 08:28:36 +02:00
Niels
44b210aa77 Merge branch 'develop' into feature/issue260 2016-06-14 08:23:09 +02:00
Niels
c744d59f2d adjusted README file to reality in Travis 2016-06-14 08:14:25 +02:00
Niels
947db6ffe3 added Xcode 8 beta 2016-06-14 08:02:29 +02:00
Niels
494cc15650 Merge branch 'develop' into feature/issue260 2016-06-07 12:13:03 +02:00
Niels
48f69f40e7 enough for today... 2016-06-07 12:04:57 +02:00
Niels
97648314a4 setting explicit path to compiler 2016-06-07 11:52:12 +02:00
Niels
439563eb04 export 2016-06-07 11:42:34 +02:00
Niels
19be324f87 ? 2016-06-07 11:38:56 +02:00
Niels
3f23e70598 another try 2016-06-07 11:36:03 +02:00
Niels
62f39c41ec another try 2016-06-07 11:29:37 +02:00
Niels
c425dc9e04 trying to install clang 2016-06-07 11:25:00 +02:00
Niels
a4058b88ec another test 2016-06-07 11:14:02 +02:00
Niels
ff8f196ca3 a test 2016-06-07 11:13:15 +02:00
Niels
31b24dd5c1 adding more Clang versions 2016-06-07 11:02:45 +02:00
Niels
cc5cad5b0b another try 2016-06-07 10:53:18 +02:00
Niels
1f04c0349a readded -lc++ 2016-06-07 10:03:18 +02:00
Niels
a97c998791 removed -lc++ 2016-06-07 09:50:43 +02:00
Niels
6d19bd1108 Revert "another try"
This reverts commit f63317dce3.
2016-06-07 09:49:11 +02:00
Niels
f63317dce3 another try 2016-06-07 09:34:46 +02:00
Niels
32cc6fefcc another try 2016-06-07 09:12:53 +02:00
Niels
fbbdcb19bc another try 2016-06-07 09:01:49 +02:00
Niels
dd10c89a3e another try 2016-06-07 08:53:36 +02:00
Niels
dd542aae7d another try 2016-06-07 08:40:25 +02:00
Niels
761880f5b7 CPATH does not work... 2016-06-07 08:32:56 +02:00
Niels
1826d12a22 added CPATH 2016-06-07 08:28:50 +02:00
Niels
dfc39b95ab clang does not work with travis right now 2016-06-07 07:54:00 +02:00
Niels
32f6682177 another try 2016-06-07 07:25:11 +02:00
Niels
f4ae8f8e2e another try 2016-06-07 07:21:17 +02:00
Niels
e772f06f0d another try 2016-06-07 07:14:54 +02:00
Niels
5173c16222 another try 2016-06-07 07:07:42 +02:00
Niels
744bae7fc4 trying to fix Travis 2016-06-07 07:00:31 +02:00
Niels
9e2dfd19e8 minor cleanup 2016-06-07 00:20:53 +02:00
Niels
b508d1f1c4 fix proposal for #260 2016-06-06 18:50:39 +02:00
Niels
04e1e7b586 cleanup 2016-05-29 14:56:08 +02:00
Niels
aa8aa3ba9f overworked coverity stuffy 2016-05-29 14:06:43 +02:00
Niels
6bdb883b5c ignore build errors for coverity-scan 2016-05-29 13:32:36 +02:00
Niels
c0b2c6ea5d removing beta-xcode6.3 for now 2016-05-29 13:06:27 +02:00
Niels
6fed416125 fixed used compiler 2016-05-29 12:57:09 +02:00
Niels
b26582c0e9 another try for coverity-scan 2016-05-29 12:29:46 +02:00
Niels
1cc77a5fe5 another try for coverity-scan 2016-05-29 12:15:13 +02:00
Niels
91dfc723be added coverity_scan 2016-05-29 12:07:20 +02:00
Niels
7bdfde4493 added a note about different NDKs (see #219) 2016-05-28 16:06:41 +02:00
Niels
71a7746ccb removed a line 2016-05-25 21:55:03 +02:00
Niels
a3f432b3dd added hint to Homebrew 2016-05-18 22:23:35 +02:00
Niels
25d60b7bab Merge pull request #247 from robertmrk/feature/cmake-cleanup
Define CMake/CTest tests
2016-05-18 22:20:45 +02:00
Niels
837617122a fixed #246 2016-05-18 22:17:08 +02:00
Robert Marki
639d63217e Define CMake/CTest tests
Instead of copying the test executable and the JSON files used by
the tests at install time, define CMake/CTest tests for running
the json_unit executable from any build directory with the project's
source directory as its working directory.

- call enable_testing in the main lists file to allow the definition
of tests
- remove install commands from the test directory's lists file
- define two tests
  - json_unit_default for running the default tests by executing
json_unit without any arguments
  - json_unit_all for running all the tests by executing json_unit
with the "*" argument
- update the AppVeyor configuration file to use the new testing method
2016-05-18 11:53:49 +02:00
Niels
0a393b8374 indentation cleanup 2016-05-12 07:34:36 +02:00
Niels
0e0ecb2c14 fixed a warning and update ChangeLog 2016-05-12 00:32:18 +02:00
Niels
fb06356856 thanks 2016-05-11 20:58:11 +02:00
Niels
888d022573 Merge pull request #242 from ChrisKitching/outOfTree
Out of tree builds and a few other miscellaneous CMake cleanups.
2016-05-11 20:52:45 +02:00
Niels
f1e61896fb fixed a shadow error 2016-05-11 18:43:12 +02:00
Niels
db5c9ec9ba fixed issue #239 (-Wconversion warnings) 2016-05-11 17:25:59 +02:00
Niels
91aa4c9def Merge branch 'develop' into feature/issue239 2016-05-11 17:23:01 +02:00
Chris Kitching
0e2f0c4edc Repair appveyor... Horrifyingly
It's sort of gnarly that it's still doing in-tree builds, but I
really, _really_ don't want to get any more friendly with CMake's
Visual Studio generator to work out how to make it stop doing it.

In-tree builds still work, after all, and the goal of this work is
to make out-of-tree builds work as well. Notional horrors like
this will have to wait ;)
2016-05-11 14:02:53 +01:00
Chris Kitching
527a69bb64 Install the test binary and test data. Fixes #241
The resulting install tree, when tests are enabled, looks like this:

```
.
├── cmake
│   ├── nlohmann_jsonConfig.cmake
│   ├── nlohmann_jsonConfigVersion.cmake
│   └── nlohmann_jsonTargets.cmake
├── include
│   └── nlohmann
│       └── json.hpp
└── test
    ├── bin
    │   └── json_unit
    └── data
        ├── json_nlohmann_tests
        │   ├── all_unicode.json
        │   └── bom.json
        ├── json.org
        │   ├── 1.json
        │   ├── ...
        ├── json_roundtrip
        │   ├── roundtrip01.json
        │   ├── roundtrip02.json
        │   └── ...
        ├── json_tests
        │   ├── fail10.json
        │   └── ...
        └── json_testsuite
            └── sample.json
```

It has the property that you can invoke the test binary from the
root of the install tree and the tests work correctly (you no
longer depend on the test binary being run inside the source
tree).

If tests are disabled, the entire `test/` subtree is omitted.
Notice how that yields exactly what you want for using this
library in other projects.

I do not believe I need to update travis due to this change, as the
evil Makefile continues to do in-tree builds. I expect I'll find
out soon enough.
2016-05-11 01:43:42 +01:00
Chris Kitching
af76508fe7 Introduce structure to the test/ directory
This introduces a clear separation between test data and test
binaries. Test data is moved into test/data, and the test binaries
move into test/src. A new CMake script specific to building the
tests is introduced in /test to slightly clean up the toplevel
one.

As well as tidying things up, this makes the next step trivial...
2016-05-11 01:30:08 +01:00
Chris Kitching
4e6aacda36 Use definitely-unique target/project name
There exist lots of json libraries, and project/target names must
be globally unique. If someone integrated with this library in a
particularly stupid way, using a generic name like "json" might
cause a problem.
2016-05-11 01:14:56 +01:00
Chris Kitching
b6becce8fb Don't use variable for the test target name
I'm not sure that using a variable for target names really helps
with clarity. Unlike paths, target names aren't really something
you change. In a sense, targets are themselves a sort of variable,
so having a variable to name a variable seems just a bit gnarly.
2016-05-11 01:12:56 +01:00
Chris Kitching
bf7b6d15c7 Unset execute bit on sample.json 2016-05-11 01:10:29 +01:00
Chris Kitching
6a98a6c964 Add CMake option to disable building the tests (Default builds) 2016-05-11 01:06:32 +01:00
Niels
9ecf83f630 working on #235 2016-05-08 20:28:20 +02:00
Niels
6d8e00ade8 another try to remove a warning 2016-05-08 17:17:17 +02:00
Niels
ac3036dc0f Merge branch 'develop' into feature/issue239 2016-05-08 17:07:08 +02:00
Niels
fadf286653 added test case for std::bad_alloc 2016-05-08 14:35:32 +02:00
Niels
85a30813c8 removed unnecessary code (numbers must not begin with "+") 2016-05-07 20:22:58 +02:00
Niels
688cd49bdc Merge branch 'feature/json-patch' into develop 2016-05-07 18:41:02 +02:00
Niels
c04275966f improved test coverage 2016-05-07 18:33:43 +02:00
Niels
9073b2ca39 hopefully removed some warnings 2016-04-30 16:22:27 +02:00
Niels
ea84a85b13 simplified flatten/unflatten examples 2016-04-30 10:39:03 +02:00
Niels
a21f8b0c77 added AppVeyor information 2016-04-30 01:21:35 +02:00
Niels
9170740f45 added documentation on Travis compilers 2016-04-30 01:01:41 +02:00
Niels
7c04bc3db6 added name call 2016-04-30 00:43:33 +02:00
Niels
be16d005e4 get compiler versions 2016-04-30 00:25:11 +02:00
Niels
f4ecceab19 cleanup 2016-04-30 00:12:19 +02:00
Niels
1d3b4dd158 added test cases 2016-04-30 00:03:47 +02:00
Niels
62f81a60d7 hopefully fixed a warning 2016-04-29 21:23:13 +02:00
Niels
82f5332cf4 Merge branch 'develop' into feature/json-patch 2016-04-29 20:50:34 +02:00
Niels
74544b42af removed MinGW compiler (too old) 2016-04-29 20:48:47 +02:00
Niels
c019088d3b wrong MinGW binary 2016-04-29 20:35:40 +02:00
Niels
b685737d53 added MinGW 2016-04-29 20:18:20 +02:00
Niels
ddc5442c91 cleanup 2016-04-29 20:09:41 +02:00
Niels
a07cdb14ec don't install valgrind for OSX 2016-04-29 20:01:11 +02:00
Niels
40abeb28d5 Valgrind only for Linux 2016-04-29 20:00:33 +02:00
Niels
68c50073a4 added OSX 2016-04-29 19:46:37 +02:00
Niels
ca604c5a2e trying Clang 3.9 2016-04-29 19:37:52 +02:00
Niels
86d7e3090f removed GCC 6, added Clang 3.5 2016-04-29 19:33:43 +02:00
Niels
e35805cf3a added GCC 6 and Clang 3.8 to Travis 2016-04-29 19:29:02 +02:00
Niels
86debab3b1 Merge branch 'develop' into feature/json-patch 2016-04-26 20:43:02 +02:00
Niels
9af8f7d094 update after #238 2016-04-26 20:38:01 +02:00
Niels
7dc07b75de Merge branch 'develop' into feature/json-patch 2016-04-26 20:32:24 +02:00
Niels
0f64761663 Merge pull request #238 from robertmrk/cmake-package
Implement additional integration options
2016-04-26 20:31:19 +02:00
Niels
5e0bf75d60 cleanup, test, and diff 2016-04-25 23:17:04 +02:00
Robert Marki
192a692034 Generate package config files in cmake's current binary directory
Generate the config files of the package in CMAKE_CURRENT_BINARY_DIR
instead of CMAKE_BINARY_DIR because the later will refer to the main
project's binary directory if the library is included in the project
using the add_subdirectory command.
2016-04-25 11:55:03 +02:00
Robert Marki
b1a2e9a715 Create an install target for the project
- define the project's version in the cmake listfile
- create a config and config version file for the cmake package
- install the json.hpp file and the package's targets, config and
config version files
2016-04-25 10:27:19 +02:00
Robert Marki
30e396043a Export library target and store build directory in package registry 2016-04-25 09:36:05 +02:00
Robert Marki
28f73ed406 Refactor CMake listfile to define an interface imported library
Define the library as an interface imported library so other targets
can use the library as a dependency and use the interface properties
of the library.
2016-04-24 19:56:20 +02:00
Niels
96cfe7463f fixed some warnings 2016-04-24 19:09:12 +02:00
Niels
8d4cf5ef8d oops 2016-04-24 19:04:10 +02:00
Niels
fb54e212b6 clean up and added tests 2016-04-24 19:03:33 +02:00
Niels
09e9f6dcd4 implemented "move" 2016-04-24 17:43:27 +02:00
Niels
855cf2307b extended "add" to cope with arrays 2016-04-24 16:51:06 +02:00
Niels
397ada22d3 implemented remove 2016-04-20 16:52:00 +02:00
Niels
fa03cf0c63 replace and copy 2016-04-20 15:41:33 +02:00
Niels
70fc5835cb started implementing JSON Patch (RFC 6902) 2016-04-18 22:41:36 +02:00
Niels
3ca1bfdd9d made a function static 2016-04-17 23:41:52 +02:00
Niels
f4107d0d9c updated documentation 2016-04-17 23:36:37 +02:00
Niels
9f8da4c650 Merge branch 'feature/json-pointer' into develop 2016-04-17 23:23:34 +02:00
Niels
08c97df420 added examples 2016-04-17 23:18:07 +02:00
Niels
1dee40a969 fixed test case 2016-04-17 22:34:39 +02:00
Niels
6268287940 improved documentation and test coverage 2016-04-17 22:08:21 +02:00
Niels
7034ae2486 improved test coverage 2016-04-17 19:12:12 +02:00
Niels
0835eb293f improved RFC compliance and code coverage 2016-04-17 18:54:54 +02:00
Niels
f883a04c87 more documentation 2016-04-17 18:18:49 +02:00
Niels
40e899a819 cleanup and documentation 2016-04-17 17:39:35 +02:00
Niels
f834965b44 implemented deflatten function 2016-04-16 20:45:40 +02:00
Niels
007359675b added a flatten function 2016-04-16 16:39:20 +02:00
Niels
3401954f5b cleaned up API 2016-04-16 14:02:14 +02:00
Niels
3a3e064287 Merge branch 'develop' into feature/json-pointer 2016-04-16 12:19:31 +02:00
Niels
76a5a776eb cleanup after #234 2016-04-16 12:19:10 +02:00
Niels
6f0053a254 Merge branch 'support-move-iterators' of https://github.com/robertmrk/json into develop 2016-04-16 12:12:16 +02:00
Niels
94af8abdff overworked reference token parsing 2016-04-13 23:23:54 +02:00
Niels
2cb925c186 adding support for escaped reference tokens 2016-04-13 17:41:19 +02:00
Robert Marki
2197f5f0a6 Make the indirection and dereference operators of iterator const
fixes #233
2016-04-13 13:49:53 +02:00
Niels
726051e9b7 very first draft of a JSON pointer API 2016-04-11 23:17:03 +02:00
Niels
507322e6f2 updated ChangeLog 2016-04-10 19:36:09 +02:00
Niels
15f8c848fa fixed typo and indentation 2016-04-10 18:23:43 +02:00
Niels
170b70f082 Merge pull request #232 from nlohmann/issue228
make serialization locale-independent (fixes #228)
2016-04-07 17:16:58 +02:00
Niels
a744c62696 made tests independent of "C" locale 2016-04-05 22:28:27 +02:00
Niels
0b60d970e9 make code independent of concrete locale 2016-04-05 22:12:12 +02:00
Niels
31bccc83b9 fixed locale problems 2016-04-05 21:55:51 +02:00
Niels
43ee70cef8 revert changes to master 2016-04-05 20:47:47 +02:00
Niels
44a8e9bf35 locale-independent dump 2016-04-03 16:33:30 +02:00
Niels
9c233be567 merged #201 2016-04-03 14:08:38 +02:00
Niels
04edafbddc Merge pull request #227 from kevin--/kevin--/noexcept_documentation
fixes #223 by updating README.md
2016-03-30 20:21:35 +02:00
Niels
1baa5a7350 fixed #225 2016-03-30 20:18:34 +02:00
Niels
0951a1f94c Merge pull request #222 from Teemperor/fixAndroid
Added missing cerrno header to fix ERANGE compile error on android
2016-03-30 20:12:55 +02:00
Niels
96443b0b97 added more thanks to the README file 2016-03-30 19:47:08 +02:00
Niels
27530c7840 better notes for Android (manually closes #215) 2016-03-30 19:42:54 +02:00
Niels
888635b749 cleanup after PR #212 and PR #226 2016-03-30 19:23:11 +02:00
Kevin Dixon
3df5337e79 fixes #223 by updating README.md 2016-03-29 21:41:46 -07:00
Niels
54d3cab568 Merge pull request #226 from lv-zheng/fix_int64
Use namespace std for int64_t and uint64_t
2016-03-29 10:35:24 +02:00
Lv Zheng
3e76e61b9c Use namespace std for int64_t and uint64_t
According to the c++11 standard, the declarations are within namespace
scope of the namespace `std'. Add `std::' to avoid unnecessary
requirement of implementations.
2016-03-28 18:11:12 +08:00
Niels
2f63e5fb45 added copyright information to files to make release more self-contained 2016-03-25 17:41:36 +01:00
Raphael Isemann
fbc25b080b Added missing cerrno header to fix ERANGE c-error on android 2016-03-10 08:46:26 +01:00
Niels
c6a6a024f7 fixes #214 2016-03-06 20:03:05 +01:00
Niels
10a884473e fixed #217 2016-03-04 07:30:08 +01:00
Niels
8ee3d24046 Merge pull request #218 from Annihil/master
Corrected readme
2016-03-04 07:26:27 +01:00
Annihil
78a020354d Corrected readme
Internally, the elements in a map are always sorted by its key following a specific strict weak ordering criterion indicated by its internal comparison object (of type Compare).
With string type, the default comparator is alphabetical order, and thus two come after three.
2016-03-02 02:01:40 +01:00
Niels
53879f9c99 cleanup 2016-02-21 08:17:11 +01:00
Niels
502cedf70b Merge pull request #213 from whackashoe/patch-1
Create PULL_REQUEST_TEMPLATE.md
2016-02-21 08:15:46 +01:00
Jett LaRue
df3ab06f2e Create PULL_REQUEST_TEMPLATE.md 2016-02-20 16:22:46 -06:00
Niels
f965c4c35b improved code coverage 2016-02-14 22:56:51 +01:00
Niels
d869b0a387 updated online documentation 2016-02-14 22:28:56 +01:00
Niels
3a92559fa9 cleanup 2016-02-14 22:24:45 +01:00
Niels
09654b3104 Merge pull request #208 from nlohmann/noexcept
fixed noexcept; added constexpr
2016-02-14 22:18:39 +01:00
Niels
f160f33fb5 update from master 2016-02-14 21:44:00 +01:00
Niels
7f4736b546 added serialization to fuzz testing 2016-02-14 21:36:56 +01:00
Niels
a3eecdc383 updated Catch to v1.3.4 2016-02-14 21:36:43 +01:00
Niels
153e105164 cleanup after #207 2016-02-14 18:38:29 +01:00
Niels
ec098ffcc2 Merge pull request #207 from msm-/afl-fuzz
add support for afl-fuzz testing
2016-02-14 17:24:54 +01:00
Niels
49dc2dff68 fixed error when compiled with Clang 2016-02-14 16:58:24 +01:00
Niels
836fdfedf2 fixed an error in MSVC 2016-02-14 16:53:32 +01:00
Niels
a69b1a6f0b added noexcept and constexpr 2016-02-14 16:42:48 +01:00
Michael Macnair
9e500b49ac Add support for afl-fuzz testing
"make fuzz" creates a simple executable that de-serialises stdin
and re-serialises to stdout.
"make fuzz_testcases" extracts the smaller json test cases into
a testcases directory.

The library can then be fuzzed as follows:
    CC=afl-clang-fast make fuzz
    make fuzz_testcases
    mkdir out
    afl-fuzz -i testcases -o out ./fuzz
2016-02-12 09:35:08 +00:00
Niels
61fe90f998 Merge pull request #205 from nlohmann/issue204
replaced ssize_t occurrences with auto (fixes #204)
2016-02-10 21:41:55 +01:00
Niels
a831c787df try to replace std::ptrdiff_t with auto (for #204) 2016-02-10 21:19:31 +01:00
Niels
4cc4b26dd2 try to replace ssize_t occurrences with std::ptrdiff_t (for #204) 2016-02-10 21:09:52 +01:00
Niels
1cc4717582 tried Clang 3.9 2016-02-09 21:26:40 +01:00
Niels
be20555985 removed gitter 2016-02-07 17:24:51 +01:00
Niels
236b7afff5 updated and fixed online version 2016-02-07 15:07:17 +01:00
Niels
fdfb39d949 improved documentation 2016-02-07 14:55:29 +01:00
Niels
3b776c08c7 clarified documentation 2016-02-07 10:45:52 +01:00
Niels
8b1a777d36 reverted change wrt. Erasable concept 2016-02-05 22:37:28 +01:00
Niels
2ff2e10660 checking Erasable concept 2016-02-05 22:30:37 +01:00
Niels
ae5bd307a2 improved documentation 2016-02-05 22:30:25 +01:00
Niels
2c720b26ab added a constructor from an input stream 2016-02-05 19:24:42 +01:00
Niels
104c4b5286 improve code coverage 2016-01-31 15:04:38 +01:00
Niels
6aa881988d improved documentation 2016-01-31 13:05:39 +01:00
Niels
22127a4b85 moved documentation to index markdown file 2016-01-30 22:05:01 +01:00
Niels
740239cef8 added a note about GCC 4.8 (#163) 2016-01-30 21:17:08 +01:00
Niels
36719fdb18 using re2c 0.16 (minimized automaton) 2016-01-30 20:33:31 +01:00
Niels
9d063d90e3 removed "using namespace" from examples 2016-01-30 20:23:14 +01:00
Niels
ade2f7c92d updated ChangeLog 2016-01-30 16:51:53 +01:00
Niels
2224435f9b cleanup after #200 2016-01-30 13:36:15 +01:00
Niels
cd44e43457 Merge pull request #200 from twelsby/issue199
Fixed issue #199 - Small bugs in json.hpp (get_number) and unit.cpp (non-standard integer type test)
2016-01-30 13:32:22 +01:00
Trevor Welsby
561accb068 Fixed issue #199 2016-01-30 12:41:12 +10:00
Niels
ff6f723195 removed token 2016-01-26 23:30:51 +01:00
Niels
3dfa56795f added note 2016-01-26 23:27:07 +01:00
Niels
1c80c2231f linked releases in ChangeLog 2016-01-26 23:10:52 +01:00
Niels
89b07bd3af added (generated) changelog 2016-01-26 22:59:57 +01:00
Niels
91c58a77a1 added Gitter to Travis 2016-01-26 21:49:20 +01:00
Niels
fb239fe645 trying Gitter 2016-01-26 21:42:51 +01:00
Niels
2468631dc9 overworked examples 2016-01-26 20:07:03 +01:00
Niels
707732a53e clean up after #193 2016-01-26 19:50:49 +01:00
Niels
e46cc6327f Merge pull request #193 from twelsby/issue178
Issue #178 - Extending support to full uint64_t/int64_t range and unsigned type (updated)
2016-01-26 19:40:16 +01:00
Niels
d338042e3e added note to warn about floating-point exceptions (#181) 2016-01-26 19:21:46 +01:00
Niels
11ae1d0f09 cleanup after #196 2016-01-26 19:13:03 +01:00
Niels
077fb1d540 Merge pull request #196 from twelsby/issue195
Issue #195 - update Travis to Trusty due to gcc/clang strtod() bug
2016-01-26 19:12:36 +01:00
Niels
b630ce0e78 thanks 2016-01-26 19:11:58 +01:00
Niels
8deaabb289 Merge pull request #197 from m-click/fix_broken_link
Fix broken link
2016-01-26 19:10:46 +01:00
Volker Diels-Grabsch
08fd6dbf98 Fix broken link 2016-01-26 15:22:15 +01:00
Trevor Welsby
2de94365de Revert to llvm-toolchain-precise-* due to Travis white-list issue 2016-01-26 09:14:43 +10:00
Trevor Welsby
a4a88b1b7d Issue #195 - update Travis to Trusty due to gcc/clang strtod() bug 2016-01-26 08:36:18 +10:00
Niels
2b13711009 updated online version 2016-01-24 23:02:28 +01:00
Niels
c09d03fba7 fixed documentation 2016-01-24 22:43:00 +01:00
Niels
31093694ce fixed version number 2016-01-24 22:21:27 +01:00
Niels
aee99b362d some editing 2016-01-24 19:24:06 +01:00
Trevor Welsby
0f28c69499 Merge upstream commits and resolve conflicts 2016-01-25 02:48:38 +10:00
Trevor Welsby
281492c581 Merge upstream commits and resolve conflicts 2016-01-25 02:42:20 +10:00
Niels
54a4139157 cleanup after #191 2016-01-24 17:33:46 +01:00
Trevor Welsby
4620960b72 Disable problematic test for GCC/clang, remove debug dump from unit.cpp 2016-01-25 02:22:46 +10:00
Niels
ad5d1dabb2 Merge pull request #191 from twelsby/issue186
Fixed Issue #186 - add strto(f|d|ld) overload wrappers, "-0.0" special case and FP trailing zero
2016-01-24 17:21:22 +01:00
Trevor Welsby
81b7079255 Kill unused argument warnings in GCC/clang 2016-01-25 02:13:39 +10:00
Trevor Welsby
19918b948d Fix typo in preprocessor defined/!defined 2016-01-25 02:07:49 +10:00
Niels
9584a99a43 added issue stats 2016-01-24 17:06:36 +01:00
Trevor Welsby
421affd06e Merge upstream commits and resolve conflicts 2016-01-25 02:01:01 +10:00
Trevor Welsby
4d6985d4e2 Disable problematic test for GCC/clang, remove debug dump from unit.cpp 2016-01-25 01:53:32 +10:00
Niels
dfb01c659b added more comments 2016-01-24 16:42:45 +01:00
Niels
3245a0dc06 fixed #194 2016-01-24 16:42:13 +01:00
Trevor Welsby
12ef668335 Merge upstream commits and resolve conflicts 2016-01-25 01:15:13 +10:00
Trevor Welsby
d7ef2ccffd Issue #178 - fully support int64_t/uint64_t numbers, add unsigned type 2016-01-25 01:04:37 +10:00
Niels
8b6e0dc02d small addition 2016-01-24 13:28:16 +01:00
Niels
d7d1e55648 applied include-what-you-use 2016-01-24 13:28:08 +01:00
Niels
8a0490a011 cleanup 2016-01-24 13:04:55 +01:00
Niels
e00b00fea8 Merge pull request #190 from twelsby/issue185
fixed #185 - remove approx() and use #pragma to kill warnings
2016-01-24 12:55:40 +01:00
Niels
600ad330c5 cleanup after PR #189 2016-01-24 11:00:54 +01:00
Niels
21a44da89d Merge pull request #189 from twelsby/issue171
Fixed Issue #171 - added two extra template overloads of operator[] for T* arguments
2016-01-24 10:47:26 +01:00
Trevor Welsby
f79d52b973 DEBUG ONLY: DUMP INFO FROM TRAVIS 2016-01-24 19:15:30 +10:00
Trevor Welsby
c1f5f0451d Add workaround for gcc < 5 not supporting std::defaultfloat 2016-01-24 17:54:50 +10:00
Trevor Welsby
bd8db5d40e Remove VS induced tabs 2016-01-24 17:15:44 +10:00
Trevor Welsby
a1c6f16bd3 Fix Issue #186 - add overload wrappers for strto(f|d|ld) 2016-01-24 17:00:11 +10:00
Trevor Welsby
3a1403409f Issue #185 - remove approx() and use #pragma to kill warnings 2016-01-23 17:45:30 +10:00
Trevor Welsby
bd0f3001c6 Fix typo in new unit.hpp comments 2016-01-23 17:31:58 +10:00
Trevor Welsby
7e3245786c Fixed issue #171 - added extra operator[] template overloads 2016-01-23 17:03:45 +10:00
Trevor Welsby
9de14a4861 Fixed issue #167 - removed operator ValueType() condition for VS2015 2016-01-23 16:34:15 +10:00
Niels
f854410542 added a note wrt. Valgrind (#175) 2016-01-20 21:20:41 +01:00
Niels
5c4624c351 wishlist 2016-01-20 21:15:10 +01:00
Niels
a04bd4f851 cleanup after #184 2016-01-20 21:14:58 +01:00
Niels
663ad13fc3 Merge pull request #184 from dariomt/master
Implementation of get_ref()
2016-01-20 20:58:44 +01:00
dariomt
db3c7fdb96 added missing template keyword (required by clang) 2016-01-19 16:20:27 +01:00
dariomt
e2f0e8b945 added missing typename (required by clang/gcc) 2016-01-19 14:56:07 +01:00
dariomt
4d079d135e replicate code changes into re2c file 2016-01-18 11:32:24 +01:00
dariomt
e1645a09e9 Merge branch 'master' of https://github.com/nlohmann/json 2016-01-18 10:08:58 +01:00
Niels
72e33eec1a thanks 2016-01-15 08:24:44 +01:00
Niels
8968885c61 Merge pull request #182 from nibroc/master
Fixed some typos in CONTRIBUTING.md
2016-01-15 07:21:07 +01:00
Corbin Hughes
8ecccf8628 Fixed some typos in CONTRIBUTING.md 2016-01-14 22:36:39 -06:00
Niels
c0bb5a56eb added note on assertions (#168) 2016-01-13 21:08:46 +01:00
Niels
a05f27867b fixed wrong file name 2016-01-13 20:37:05 +01:00
Niels
832fe49bc1 fixed lists 2016-01-13 20:26:47 +01:00
Niels
57e018483a it's 2016 already... 2016-01-13 20:19:05 +01:00
Niels
1741e58eb5 contribution guidelines (#175) 2016-01-13 20:18:06 +01:00
Niels
4511145d3d removing unused catch variables (fixes #180) 2016-01-13 19:19:35 +01:00
Niels
151d43f63e fixing numerous typos (fixes #179) 2016-01-13 19:14:33 +01:00
Niels
4a452f11f9 added assertions (#168) 2016-01-03 17:05:27 +01:00
Niels
d27c8a8ea8 reverting OSX 2016-01-02 16:49:56 +01:00
Niels
fb7ff414ad more Valgrind information 2016-01-02 16:42:45 +01:00
Niels
2d48a36f5c trying Travis and OSX 2016-01-02 16:37:40 +01:00
Niels
b4bb3afb65 removed clang 3.8 2016-01-02 15:42:56 +01:00
Niels
4a87ed4441 trying Clang 3.8 2016-01-02 15:34:34 +01:00
Niels
33abe87407 forgot version number 2016-01-02 15:30:12 +01:00
Niels
dbf58ae9c0 trying to add Clang 3.7 toolchain 2016-01-02 15:24:13 +01:00
Niels
7614aa31c0 cleanup 2016-01-02 13:07:22 +01:00
Niels
9b07504e23 fix for #166 2016-01-01 18:33:58 +01:00
Niels
3905406f9c removed an unnecessary cast (fixed #162) 2015-12-29 12:30:05 +01:00
Niels
aca6a3b373 version number 2015-12-28 15:04:15 +01:00
Niels
cb5581392a preparing 1.0.0 release 2015-12-28 14:51:57 +01:00
dariomt
4b8a822f33 Merge branch 'get_ref' 2015-10-16 16:42:03 +02:00
dariomt
95090a7ddd Merge branch 'patch-2' 2015-10-16 16:40:57 +02:00
dariomt
5198e1f2e4 removed const in get_ptr() by accident 2015-10-16 15:45:47 +02:00
dariomt
bd2783f45c Added get_ref()
Same as get_ptr() but for references.
If the type is incompatible it throws (get_ptr() returns null).
Implemented in terms of get_ptr().
2015-10-16 15:23:57 +02:00
Dario Menendez
8f97e99feb Merge remote-tracking branch 'origin/patch-3' 2015-10-16 11:23:19 +02:00
Dario Menendez
8d53c5e06f Merge remote-tracking branch 'origin/patch-2' 2015-10-16 11:22:57 +02:00
353 changed files with 13903 additions and 3593 deletions

75
.github/CONTRIBUTING.md vendored Normal file
View File

@@ -0,0 +1,75 @@
[![Issue Stats](http://issuestats.com/github/nlohmann/json/badge/pr?style=flat)](http://issuestats.com/github/nlohmann/json) [![Issue Stats](http://issuestats.com/github/nlohmann/json/badge/issue?style=flat)](http://issuestats.com/github/nlohmann/json)
# How to contribute
This project started as a little excuse to exercise some of the cool new C++11 features. Over time, people actually started to use the JSON library (yey!) and started to help improve it by proposing features, finding bugs, or even fixing my mistakes. I am really [thankful](https://github.com/nlohmann/json/blob/master/README.md#thanks) for this and try to keep track of all the helpers.
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!
## 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.
If you want propose changes to the code, you need to download the [`re2c`](http://re2c.org) tool.
## Describe your issue
Clearly describe the issue:
- If it is a bug, please describe how to **reproduce** it. If possible, attach a complete example which demonstrates the error. Please also state what you **expected** to happen instead of the error.
- If you propose a change or addition, try to give an **example** how the improved code could look like or how to use it.
- If you found a compilation error, please tell us which **compiler** (version and operating system) you used and paste the (relevant part of) the error messages to the ticket.
## Files to change
There are currently two files which need to be edited:
1. [`src/json.hpp.re2c`](https://github.com/nlohmann/json/blob/master/src/json.hpp.re2c) (note the `.re2c` suffix) - This file contains a comment section which describes the JSON lexic. This section is translated by [`re2c`](http://re2c.org) into file [`src/json.hpp`](https://github.com/nlohmann/json/blob/master/src/json.hpp) which is plain "vanilla" C++11 code. (In fact, the generated lexer consists of some hundred lines of `goto`s, which is a hint you never want to edit this file...).
If you only edit file `src/json.hpp` (without the `.re2c` suffix), your changes will be overwritten as soon as the lexer is touched again. To generate the `src/json.hpp` file which is actually used during compilation of the tests and all other code, please execute
```sh
make re2c
```
To run [`re2c`](http://re2c.org) and generate/overwrite file `src/json.hpp` with your changes in file `src/json.hpp.re2c`.
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
```sh
make
```
and can be executed with
```sh
./json_unit
```
The test cases are also executed with several different compilers on [Travis](https://travis-ci.org/nlohmann/json) once you open a pull request.
Please understand that I cannot accept pull requests changing only file `src/json.hpp`.
## 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.
## Please don't
- 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.
- Please do not open pull requests that address **multiple issues**.
## Wanted
The following areas really need contribution:
- Extending the **continuous integration** toward more exotic compilers such as Android NDK, Intel's Compiler, or the bleeding-edge versions of GCC or Clang.
- Improving the efficiency of the **JSON parser**. The current parser is implemented as a naive recursive descent parser with hand coded string handling. More sophisticated approaches like LALR parsers would be really appreciated. That said, parser generators like Bison or ANTLR do not play nice with single-header files -- I really would like to keep the parser inside the `json.hpp` header, and I am not aware of approaches similar to [`re2c`](http://re2c.org) for parsing.
- Extending and updating existing **benchmarks** to include (the most recent version of) this library. Though efficiency is not everything, speed and memory consumption are very important characteristics for C++ developers, so having proper comparisons would be interesting.

46
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,46 @@
## Files to change
There are currently two files which need to be edited:
1. [`src/json.hpp.re2c`](https://github.com/nlohmann/json/blob/master/src/json.hpp.re2c) (note the `.re2c` suffix) - This file contains a comment section which describes the JSON lexic. This section is translated by [`re2c`](http://re2c.org) into file [`src/json.hpp`](https://github.com/nlohmann/json/blob/master/src/json.hpp) which is plain "vanilla" C++11 code. (In fact, the generated lexer consists of some hundred lines of `goto`s, which is a hint you never want to edit this file...).
If you only edit file `src/json.hpp` (without the `.re2c` suffix), your changes will be overwritten as soon as the lexer is touched again. To generate the `src/json.hpp` file which is actually used during compilation of the tests and all other code, please execute
```sh
make re2c
```
To run [`re2c`](http://re2c.org) and generate/overwrite file `src/json.hpp` with your changes in file `src/json.hpp.re2c`.
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
```sh
make
```
and can be executed with
```sh
./json_unit
```
The test cases are also executed with several different compilers on [Travis](https://travis-ci.org/nlohmann/json) once you open a pull request.
Please understand that I cannot accept pull requests changing only file `src/json.hpp`.
## 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.
## Please don't
- 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.
- Please do not open pull requests that address **multiple issues**.

9
.gitignore vendored
View File

@@ -1,7 +1,16 @@
json_unit
json_benchmarks
fuzz-testing
*.dSYM
working
html
me.nlohmann.json.docset
android
doc/xml
benchmarks/files/numbers/*.json

View File

@@ -1,6 +1,13 @@
language: cpp
sudo: false
dist: trusty
sudo: required
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
matrix:
@@ -13,32 +20,157 @@ matrix:
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
- os: linux
compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-5', 'valgrind']
env: COMPILER=g++-5
packages: ['g++-6', 'valgrind']
env: COMPILER=g++-6
# 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 3.5 is not able to compile the code,
# see https://travis-ci.org/nlohmann/json/jobs/126720186
# - 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: clang
# addons:
# apt:
# sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise']
# packages: ['clang-3.9', 'valgrind']
# env: COMPILER=clang++-3.9
- os: osx
osx_image: beta-xcode6.1
compiler: clang
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
packages: ['clang-3.6', 'valgrind']
env: COMPILER=clang++-3.6
env:
- COMPILER=clang
- CXXFLAGS=-lstdc++
- os: osx
osx_image: beta-xcode6.2
compiler: clang
env:
- COMPILER=clang
- CXXFLAGS=-lstdc++
- os: osx
osx_image: beta-xcode6.3
compiler: clang
env:
- COMPILER=clang
- CXXFLAGS=-lstdc++
- os: osx
osx_image: xcode6.4
compiler: clang
env:
- COMPILER=clang
- CXXFLAGS=-lstdc++
- 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: osx
osx_image: xcode7.3
compiler: clang
env:
- COMPILER=clang
- CXXFLAGS=-lstdc++
- os: osx
osx_image: xcode8
compiler: clang
env:
- COMPILER=clang
- CXXFLAGS=-lstdc++
script:
- make CXX=$COMPILER CXXFLAGS="-lstdc++"
- uname -a
- $COMPILER --version
- make CXX=$COMPILER
- ./json_unit "*"
- valgrind --error-exitcode=1 --leak-check=full ./json_unit
after_success:
- if [ "$COMPILER" = "g++-4.9" ]; then make clean ; fi
- if [ "$COMPILER" = "g++-4.9" ]; then touch src/json.hpp ; fi
- if [ "$COMPILER" = "g++-4.9" ]; then make json_unit CXXFLAGS="-fprofile-arcs -ftest-coverage -std=c++11 -lstdc++" CXX=$COMPILER ; fi
- if [ "$COMPILER" = "g++-4.9" ]; then ./json_unit "*" ; fi
- if [ "$COMPILER" = "g++-4.9" ]; then coveralls --exclude test/catch.hpp --exclude test/unit.cpp --include src/json.hpp --gcov-options '\-lp' --gcov 'gcov-4.9' ; fi
- if [ `which valgrind` ]; then
valgrind --error-exitcode=1 --leak-check=full ./json_unit ;
fi
- if [ `which brew` ]; then
brew update ;
brew tap nlohmann/json ;
brew install nlohmann_json --HEAD ;
brew test nlohmann_json ;
fi

View File

@@ -1,25 +1,54 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.0)
project(json CXX)
# define the project
project(nlohmann_json VERSION 2.0.2 LANGUAGES CXX)
add_executable(json_unit
src/json.hpp test/catch.hpp test/unit.cpp
)
enable_testing()
if(MSVC)
set(CMAKE_CXX_FLAGS
"/EHsc"
)
option(BuildTests "Build the unit tests" ON)
STRING(REPLACE "/O2" "/Od" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
# define project variables
set(JSON_TARGET_NAME ${PROJECT_NAME})
set(JSON_PACKAGE_NAME ${JSON_TARGET_NAME})
set(JSON_TARGETS_FILENAME "${JSON_PACKAGE_NAME}Targets.cmake")
set(JSON_CONFIG_FILENAME "${JSON_PACKAGE_NAME}Config.cmake")
set(JSON_CONFIGVERSION_FILENAME "${JSON_PACKAGE_NAME}ConfigVersion.cmake")
set(JSON_CONFIG_DESTINATION "cmake")
set(JSON_INCLUDE_DESTINATION "include/nlohmann")
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
else(MSVC)
set(CMAKE_CXX_FLAGS
"-std=c++11"
)
endif(MSVC)
# create and configure the library target
add_library(${JSON_TARGET_NAME} INTERFACE)
target_include_directories(${JSON_TARGET_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:${JSON_INCLUDE_DESTINATION}>)
include_directories(
src test
)
# create and configure the unit test target
if (BuildTests)
add_subdirectory(test)
endif()
# generate a config and config version file for the package
include(CMakePackageConfigHelpers)
configure_package_config_file("cmake/config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${JSON_CONFIG_FILENAME}"
INSTALL_DESTINATION ${JSON_CONFIG_DESTINATION})
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/${JSON_CONFIGVERSION_FILENAME}"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
# export the library target and store build directory in package registry
export(TARGETS ${JSON_TARGET_NAME}
FILE "${CMAKE_CURRENT_BINARY_DIR}/${JSON_TARGETS_FILENAME}")
export(PACKAGE ${JSON_PACKAGE_NAME})
# install library target and config files
install(TARGETS ${JSON_TARGET_NAME}
EXPORT ${JSON_PACKAGE_NAME})
install(FILES "src/json.hpp"
DESTINATION ${JSON_INCLUDE_DESTINATION})
install(EXPORT ${JSON_PACKAGE_NAME}
FILE ${JSON_TARGETS_FILENAME}
DESTINATION ${JSON_CONFIG_DESTINATION})
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${JSON_CONFIG_FILENAME}"
"${CMAKE_CURRENT_BINARY_DIR}/${JSON_CONFIGVERSION_FILENAME}"
DESTINATION ${JSON_CONFIG_DESTINATION})

238
ChangeLog.md Normal file
View File

@@ -0,0 +1,238 @@
# 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)
[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.1...v2.0.2)
- 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)
- 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))
- Update hexify to use array lookup instead of ternary \(\#270\) [\#275](https://github.com/nlohmann/json/pull/275) ([dtoma](https://github.com/dtoma))
## [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)
- 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))
## [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)
- -Wconversion warning [\#259](https://github.com/nlohmann/json/issues/259)
- Maybe a bug [\#258](https://github.com/nlohmann/json/issues/258)
- -Wconversion warnings [\#239](https://github.com/nlohmann/json/issues/239)
- ambiguous overload for 'push\_back' and 'operator+=' [\#235](https://github.com/nlohmann/json/issues/235)
- 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)
- abort during getline in yyfill [\#223](https://github.com/nlohmann/json/issues/223)
- Wrong link in the README.md [\#217](https://github.com/nlohmann/json/issues/217)
- 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)
- 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)
- 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))
- make serialization locale-independent [\#232](https://github.com/nlohmann/json/pull/232) ([nlohmann](https://github.com/nlohmann))
- fixes \#223 by updating README.md [\#227](https://github.com/nlohmann/json/pull/227) ([kevin--](https://github.com/kevin--))
- 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))
- 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))
## [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)
- Android? [\#172](https://github.com/nlohmann/json/issues/172)
- 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)
- 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 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)
- 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)
- 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)
- json.hpp:5746:32: error: 'to\_string' is not a member of 'std' [\#136](https://github.com/nlohmann/json/issues/136)
- Returning any data type [\#113](https://github.com/nlohmann/json/issues/113)
- vector\<json\> copy constructor really weird [\#108](https://github.com/nlohmann/json/issues/108)
- maintaining order of keys during iteration [\#106](https://github.com/nlohmann/json/issues/106)
- 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))
- Detect correctly pointer-to-const [\#137](https://github.com/nlohmann/json/pull/137) ([dariomt](https://github.com/dariomt))
- disabled "CopyAssignable" test for MSVC in Debug mode, see \#125 [\#131](https://github.com/nlohmann/json/pull/131) ([dariomt](https://github.com/dariomt))
- removed stream operator for iterator, resolution for \#125 [\#130](https://github.com/nlohmann/json/pull/130) ([dariomt](https://github.com/dariomt))
- fixed typos in comments for examples [\#129](https://github.com/nlohmann/json/pull/129) ([dariomt](https://github.com/dariomt))
- Remove superfluous inefficiency [\#126](https://github.com/nlohmann/json/pull/126) ([d-frey](https://github.com/d-frey))
- remove invalid parameter '-stdlib=libc++' in CMakeLists.txt [\#124](https://github.com/nlohmann/json/pull/124) ([emvivre](https://github.com/emvivre))
- exception-safe object creation, fixes \#118 [\#122](https://github.com/nlohmann/json/pull/122) ([d-frey](https://github.com/d-frey))
- Fix small oversight. [\#121](https://github.com/nlohmann/json/pull/121) ([ColinH](https://github.com/ColinH))
- Overload parse\(\) to accept an rvalue reference [\#120](https://github.com/nlohmann/json/pull/120) ([silverweed](https://github.com/silverweed))
- 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)
- Adjust wording to JSON RFC [\#97](https://github.com/nlohmann/json/issues/97)
- 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)
- MinGW have no std::to\_string [\#80](https://github.com/nlohmann/json/issues/80)
- 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)
- Document erase, count, and iterators key and value [\#52](https://github.com/nlohmann/json/issues/52)
- Supported compilers [\#50](https://github.com/nlohmann/json/issues/50)
- 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)
- dumping a small number\_float just outputs 0.000000 [\#37](https://github.com/nlohmann/json/issues/37)
- 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)
- Improper parsing of JSON string "\\" [\#17](https://github.com/nlohmann/json/issues/17)
- Don't return "const values" [\#15](https://github.com/nlohmann/json/issues/15)
- 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)
- Add unit tests [\#4](https://github.com/nlohmann/json/issues/4)
- Drop C++98 support [\#3](https://github.com/nlohmann/json/issues/3)
- 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))
- Avoid warning with Xcode's clang [\#85](https://github.com/nlohmann/json/pull/85) ([ahamez](https://github.com/ahamez))
- Fix typos [\#73](https://github.com/nlohmann/json/pull/73) ([aqnouch](https://github.com/aqnouch))
- Replace `default\_callback` function with `nullptr` and check for null… [\#72](https://github.com/nlohmann/json/pull/72) ([aburgh](https://github.com/aburgh))
- 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))
- 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))
- Fix string conversion under Clang [\#26](https://github.com/nlohmann/json/pull/26) ([wancw](https://github.com/wancw))
- Fixed dumping of strings [\#24](https://github.com/nlohmann/json/pull/24) ([Teemperor](https://github.com/Teemperor))
- Added a remark to the readme that coverage is GCC only for now [\#23](https://github.com/nlohmann/json/pull/23) ([Teemperor](https://github.com/Teemperor))
- Unicode escaping [\#22](https://github.com/nlohmann/json/pull/22) ([Teemperor](https://github.com/Teemperor))
- Implemented the JSON spec for string parsing for everything but the \uXXXX escaping [\#21](https://github.com/nlohmann/json/pull/21) ([Teemperor](https://github.com/Teemperor))
- add the std iterator typedefs to iterator and const\_iterator [\#19](https://github.com/nlohmann/json/pull/19) ([kirkshoop](https://github.com/kirkshoop))
- Fixed escaped quotes [\#18](https://github.com/nlohmann/json/pull/18) ([Teemperor](https://github.com/Teemperor))
- Fix double delete on std::bad\_alloc exception [\#14](https://github.com/nlohmann/json/pull/14) ([elliotgoodrich](https://github.com/elliotgoodrich))
- Added CMake and lcov [\#6](https://github.com/nlohmann/json/pull/6) ([Teemperor](https://github.com/Teemperor))
- Version 2.0 [\#5](https://github.com/nlohmann/json/pull/5) ([nlohmann](https://github.com/nlohmann))
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*

View File

@@ -1,7 +1,7 @@
The library is licensed under the MIT License
<http://opensource.org/licenses/MIT>:
Copyright (c) 2013-2015 Niels Lohmann
Copyright (c) 2013-2016 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

View File

@@ -1,4 +1,4 @@
.PHONY: pretty clean
.PHONY: pretty clean ChangeLog.md
# used programs
RE2C = re2c
@@ -9,7 +9,9 @@ all: json_unit
# clean up
clean:
rm -f json_unit json_benchmarks
rm -fr json_unit json_benchmarks fuzz fuzz-testing *.dSYM
rm -fr benchmarks/files/numbers/*.json
$(MAKE) clean -Cdoc
##########################################################################
@@ -19,11 +21,38 @@ clean:
# 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: test/unit.cpp src/json.hpp test/catch.hpp
# 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 $@
##########################################################################
# documentation tests
##########################################################################
# compile example files and check output
doctest:
$(MAKE) check_output -C doc
##########################################################################
# fuzzing
##########################################################################
# the overall fuzz testing target
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
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"
# the fuzzer binary
fuzz: test/src/fuzz.cpp src/json.hpp
$(CXX) -std=c++11 $(CXXFLAGS) $(FLAGS) $(CPPFLAGS) -I src $< $(LDFLAGS) -o $@
##########################################################################
# static analyzer
##########################################################################
@@ -39,7 +68,7 @@ cppcheck:
# create scanner with re2c
re2c: src/json.hpp.re2c
$(RE2C) -b -s -i --no-generation-date $< | $(SED) '1d' > src/json.hpp
$(RE2C) -W --bit-vectors --nested-ifs --no-debug-info $< | $(SED) '1d' > src/json.hpp
# pretty printer
pretty:
@@ -47,8 +76,8 @@ pretty:
--indent-switches --indent-preproc-block --indent-preproc-define \
--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 \
src/json.hpp src/json.hpp.re2c test/unit.cpp benchmarks/benchmarks.cpp doc/examples/*.cpp
--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
##########################################################################
@@ -57,5 +86,18 @@ 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 $@
./json_benchmarks
##########################################################################
# changelog
##########################################################################
NEXT_VERSION ?= "unreleased"
ChangeLog.md:
github_changelog_generator -o ChangeLog.md --simple-list --release-url https://github.com/nlohmann/json/releases/tag/%s --future-release $(NEXT_VERSION)
gsed -i 's|https://github.com/nlohmann/json/releases/tag/HEAD|https://github.com/nlohmann/json/tree/HEAD|' ChangeLog.md
gsed -i '2i All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).' ChangeLog.md

165
README.md
View File

@@ -1,10 +1,11 @@
![JSON for Modern C++](https://raw.githubusercontent.com/nlohmann/json/master/doc/json.gif)
[![JSON for Modern C++](https://raw.githubusercontent.com/nlohmann/json/master/doc/json.gif)](https://github.com/nlohmann/json/releases)
[![Build Status](https://travis-ci.org/nlohmann/json.svg?branch=master)](https://travis-ci.org/nlohmann/json)
[![Build Status](https://ci.appveyor.com/api/projects/status/1acb366xfyg3qybk?svg=true)](https://ci.appveyor.com/project/nlohmann/json)
[![Coverage Status](https://img.shields.io/coveralls/nlohmann/json.svg)](https://coveralls.io/r/nlohmann/json)
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](http://melpon.org/wandbox/permlink/GnGKwji06WeVonlI)
[![Documentation Status](https://img.shields.io/badge/docs-doxygen-blue.svg)](http://nlohmann.github.io/json)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/5550/badge.svg)](https://scan.coverity.com/projects/nlohmann-json)
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](http://melpon.org/wandbox/permlink/p5o4znPnGHJpDVqN)
[![Documentation](https://img.shields.io/badge/docs-doxygen-blue.svg)](http://nlohmann.github.io/json)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nlohmann/json/master/LICENSE.MIT)
[![Github Releases](https://img.shields.io/github/release/nlohmann/json.svg)](https://github.com/nlohmann/json/releases)
[![Github Issues](https://img.shields.io/github/issues/nlohmann/json.svg)](http://github.com/nlohmann/json/issues)
@@ -15,15 +16,18 @@ There are myriads of [JSON](http://json.org) libraries out there, and each may e
- **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.
- **Trivial integration**. Our whole code consists of a single header file `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.
- **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/json_unit.cc) 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.
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` 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.
- **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).
See the [contribution guidelines](https://github.com/nlohmann/json/blob/master/.github/CONTRIBUTING.md#please-dont) for more information.
- **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) with a decent regular expression processor should be even faster (but would consist of more files which makes the integration harder).
## Integration
@@ -38,17 +42,7 @@ using json = nlohmann::json;
to the files you want to use JSON objects. That's it. Do not forget to set the necessary switches to enable C++11 (e.g., `-std=c++11` for GCC and Clang).
## Supported compilers
Though it's 2015 already, the support for C++11 is still a bit sparse. Currently, the following compilers are known to work:
- GCC 4.9 - 6.0 (and possibly later)
- Clang 3.4 - 3.8 (and possibly later)
- Microsoft Visual C++ 14.0 RC (and possibly later)
I would be happy to learn about other compilers/versions.
For GCC running on MinGW or Android SDK, the error `'to_string' is not a member of 'std'` (or similarly, for `strtod`) may occur. Note this is not an issue with the code, but rather with the compiler itself. Please refer to [this site](http://tehsausage.com/mingw-to-string) and [this discussion](https://github.com/nlohmann/json/issues/136) for information on how to fix this bug.
:beer: If you are using OS X and [Homebrew](http://brew.sh), just type `brew tap nlohmann/json` and `brew install nlohmann_json` and you're set. If you want the bleeding edge rather than the latest release, use `brew install nlohmann_json --HEAD`.
## Examples
@@ -132,6 +126,7 @@ json empty_object_explicit = json::object();
json array_not_object = { json::array({"currency", "USD"}), json::array({"value", 42.99}) };
```
### Serialization / Deserialization
You can create an object (deserialization) by appending `_json` to a string literal:
@@ -140,7 +135,7 @@ You can create an object (deserialization) by appending `_json` to a string lite
// create object from string literal
json j = "{ \"happy\": true, \"pi\": 3.141 }"_json;
// or even nicer (thanks http://isocpp.org/blog/2015/01/json-for-modern-cpp)
// or even nicer with a raw string literal
auto j2 = R"(
{
"happy": true,
@@ -183,6 +178,9 @@ std::cout << std::setw(4) << j << std::endl;
These operators work for any subclasses of `std::istream` or `std::ostream`.
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.
### STL-like access
We designed the JSON class to behave just like an STL container. In fact, it satisfies the [**ReversibleContainer**](http://en.cppreference.com/w/cpp/concept/ReversibleContainer) requirement.
@@ -200,7 +198,7 @@ for (json::iterator it = j.begin(); it != j.end(); ++it) {
}
// range-based for
for (auto element : j) {
for (auto& element : j) {
std::cout << element << '\n';
}
@@ -250,6 +248,7 @@ int fob_present = o.count("fob"); // 0
o.erase("foo");
```
### Conversion from STL containers
Any sequence container (`std::array`, `std::vector`, `std::deque`, `std::forward_list`, `std::list`) whose values can be used to construct JSON types (e.g., integers, floating point numbers, Booleans, string types, or again STL containers described in this section) can be used to create a JSON array. The same holds for similar associative containers (`std::set`, `std::multiset`, `std::unordered_set`, `std::unordered_multiset`), but in these cases the order of the elements of the array depends how the elements are ordered in the respective STL container.
@@ -292,12 +291,12 @@ json j_umset(c_umset); // both entries for "one" are used
// maybe ["one", "two", "one", "four"]
```
Likewise, any associative key-value containers (`std::map`, `std::multimap`, `std::unordered_map`, `std::unordered_multimap`) whose keys are can construct an `std::string` and whose values can be used to construct JSON types (see examples above) can be used to to create a JSON object. Note that in case of multimaps only one key is used in the JSON object and the value depends on the internal order of the STL container.
Likewise, any associative key-value containers (`std::map`, `std::multimap`, `std::unordered_map`, `std::unordered_multimap`) whose keys can construct an `std::string` and whose values can be used to construct JSON types (see examples above) can be used to to create a JSON object. Note that in case of multimaps only one key is used in the JSON object and the value depends on the internal order of the STL container.
```cpp
std::map<std::string, int> c_map { {"one", 1}, {"two", 2}, {"three", 3} };
json j_map(c_map);
// {"one": 1, "two": 2, "three": 3}
// {"one": 1, "three": 3, "two": 2 }
std::unordered_map<const char*, double> c_umap { {"one", 1.2}, {"two", 2.3}, {"three", 3.4} };
json j_umap(c_umap);
@@ -312,12 +311,51 @@ json j_ummap(c_ummap); // only one entry for key "three" is used
// maybe {"one": true, "two": true, "three": true}
```
### JSON Pointer and JSON Patch
The library supports **JSON Pointer** ([RFC 6901](https://tools.ietf.org/html/rfc6901)) as alternative means to address structured values. On top of this, **JSON Patch** ([RFC 6902](https://tools.ietf.org/html/rfc6902)) allows to describe differences between two JSON values - effectively allowing patch and diff operations known from Unix.
```cpp
// a JSON value
json j_original = R"({
"baz": ["one", "two", "three"],
"foo": "bar"
})"_json;
// access members with a JSON pointer (RFC 6901)
j_original["/baz/1"_json_pointer];
// "two"
// a JSON patch (RFC 6902)
json j_patch = R"([
{ "op": "replace", "path": "/baz", "value": "boo" },
{ "op": "add", "path": "/hello", "value": ["world"] },
{ "op": "remove", "path": "/foo"}
])"_json;
// apply the patch
json j_result = j_original.patch(j_patch);
// {
// "baz": "boo",
// "hello": ["world"]
// }
// calculate a JSON patch from two JSON values
json::diff(j_result, j_original);
// [
// { "op":" replace", "path": "/baz", "value": ["one", "two", "three"] },
// { "op": "remove","path": "/hello" },
// { "op": "add", "path": "/foo", "value": "bar" }
// ]
```
### Implicit conversions
The type of the JSON object is determined automatically by the expression to store. Likewise, the stored value is implicitly converted.
```cpp
/// strings
// strings
std::string s1 = "Hello, world!";
json js = s1;
std::string s2 = js;
@@ -345,19 +383,65 @@ int vi = jn.get<int>();
// etc.
```
## Supported compilers
Though it's 2016 already, the support for C++11 is still a bit sparse. Currently, the following compilers are known to work:
- GCC 4.9 - 6.0 (and possibly later)
- Clang 3.4 - 3.9 (and possibly later)
- Microsoft Visual C++ 2015 / Build Tools 14.0.25123.0 (and possibly later)
I would be happy to learn about other compilers/versions.
Please note:
- GCC 4.8 does not work because of two bugs ([55817](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55817) and [57824](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57824)) in the C++11 support. Note there is a [pull request](https://github.com/nlohmann/json/pull/212) to fix some of the issues.
- Android defaults to using very old compilers and C++ libraries. To fix this, add the following to your `Application.mk`. This will switch to the LLVM C++ library, the Clang compiler, and enable C++11 and other features disabled by default.
```
APP_STL := c++_shared
NDK_TOOLCHAIN_VERSION := clang3.6
APP_CPPFLAGS += -frtti -fexceptions
```
The code compiles successfully with [Android NDK](https://developer.android.com/ndk/index.html?hl=ml), Revision 9 - 11 (and possibly later) and [CrystaX's Android NDK](https://www.crystax.net/en/android/ndk) version 10.
- For GCC running on MinGW or Android SDK, the error `'to_string' is not a member of 'std'` (or similarly, for `strtod`) may occur. Note this is not an issue with the code, but rather with the compiler itself. On Android, see above to build with a newer environment. For MinGW, please refer to [this site](http://tehsausage.com/mingw-to-string) and [this discussion](https://github.com/nlohmann/json/issues/136) for information on how to fix this bug. For Android NDK using `APP_STL := gnustl_static`, please refer to [this discussion](https://github.com/nlohmann/json/issues/219).
The following compilers are currently used in continuous integration at [Travis](https://travis-ci.org/nlohmann/json) and [AppVeyor](https://ci.appveyor.com/project/nlohmann/json):
| Compiler | Operating System | Version String |
|-----------------|------------------------------|----------------|
| 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.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 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) |
| Visual Studio 14 2015 | Windows Server 2012 R2 (x64) | Microsoft (R) Build Engine version 14.0.25123.0 |
## License
<img align="right" src="http://opensource.org/trademarks/opensource/OSI-Approved-License-100x137.png">
The class is licensed under the [MIT License](http://opensource.org/licenses/MIT):
Copyright &copy; 2013-2015 [Niels Lohmann](http://nlohmann.me)
Copyright &copy; 2013-2016 [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:
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.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
## Thanks
@@ -375,20 +459,43 @@ 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.
- [gregmarr](https://github.com/gregmarr) simplified the implementation of reverse iterators and helped with numerous hints and improvements.
- [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.
- [Colin Hirsch](https://github.com/ColinH) took care of a small namespace issue.
- [Huu Nguyen](https://github.com/whoshuu) correct a variable name in the documentation.
- [Silverweed](https://github.com/silverweed) overloaded `parse()` to accept an rvalue reference.
- [dariomt](https://github.com/dariomt) fixed a subtlety in MSVC type support.
- [dariomt](https://github.com/dariomt) fixed a subtlety in MSVC type support and implemented the `get_ref()` function to get a reference to stored values.
- [ZahlGraf](https://github.com/ZahlGraf) added a workaround that allows compilation using Android NDK.
- [whackashoe](https://github.com/whackashoe) replaced a function that was marked as unsafe by Visual Studio.
- [406345](https://github.com/406345) fixed two small warnings.
- [Glen Fernandes](https://github.com/glenfe) noted a potential portability problem in the `has_mapped_type` function.
- [Corbin Hughes](https://github.com/nibroc) fixed some typos in the contribution guidelines.
- [twelsby](https://github.com/twelsby) fixed the array subscript operator, an issue that failed the MSVC build, and floating-point parsing/dumping. He further added support for unsigned integer numbers and implemented better roundtrip support for parsed numbers.
- [Volker Diels-Grabsch](https://github.com/vog) fixed a link in the README file.
- [msm-](https://github.com/msm-) added support for american fuzzy lop.
- [Annihil](https://github.com/Annihil) fixed an example in the README file.
- [Themercee](https://github.com/Themercee) noted a wrong URL in the README file.
- [Lv Zheng](https://github.com/lv-zheng) fixed a namespace issue with `int64_t` and `uint64_t`.
- [abc100m](https://github.com/abc100m) analyzed the issues with GCC 4.8 and proposed a [partial solution](https://github.com/nlohmann/json/pull/212).
- [zewt](https://github.com/zewt) added useful notes to the README file about Android.
- [Róbert Márki](https://github.com/robertmrk) added a fix to use move iterators and improved the integration via CMake.
- [Chris Kitching](https://github.com/ChrisKitching) cleaned up the CMake files.
- [Tom Needham](https://github.com/06needhamt) fixed a subtle bug with MSVC 2015 which was also proposed by [Michael K.](https://github.com/Epidal).
- [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.
Thanks a lot for helping out!
## 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).
- 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.
## Execute unit tests
To compile and run the tests, you need to execute
@@ -398,7 +505,7 @@ $ make
$ ./json_unit "*"
===============================================================================
All tests passed (3343239 assertions in 28 test cases)
All tests passed (8905012 assertions in 32 test cases)
```
For more information, have a look at the file [.travis.yml](https://github.com/nlohmann/json/blob/master/.travis.yml).

View File

@@ -7,5 +7,4 @@ build_script:
- cmake . -G "Visual Studio 14 2015"
- cmake --build . --config Release
test_script:
- Release\json_unit.exe
- Release\json_unit.exe "*"
- ctest -C Release -V

View File

@@ -44,6 +44,36 @@ BENCHMARK("parse twitter.json", [](benchpress::context* ctx)
}
})
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");

View File

@@ -0,0 +1,25 @@
#!/usr/bin/env python
import json
import random
import sys
random.seed(0)
# floats
result_floats = []
for x in range(0, 1000000):
result_floats.append(random.uniform(-100000000.0, 100000000.0))
json.dump(result_floats, open("floats.json", "w"), indent=2)
# unsigned integers
result_uints = []
for x in range(0, 1000000):
result_uints.append(random.randint(0, 18446744073709551615))
json.dump(result_uints, open("unsigned_ints.json", "w"), indent=2)
# signed integers
result_sints = []
for x in range(0, 1000000):
result_sints.append(random.randint(-9223372036854775808, 9223372036854775807))
json.dump(result_sints, open("signed_ints.json", "w"), indent=2)

6
cmake/config.cmake.in Normal file
View File

@@ -0,0 +1,6 @@
@PACKAGE_INIT@
cmake_policy(PUSH)
cmake_policy(SET CMP0024 OLD)
include(${CMAKE_CURRENT_LIST_DIR}/@JSON_TARGETS_FILENAME@)
cmake_policy(POP)

View File

@@ -1,23 +0,0 @@
# JSON for Modern C++
## Version 1.0.0-rc1
- Release date: 2015-07-26
- MD5: fac5948417ed49bfd0852a0e9dd36935
### Summary
The 1.0.0 release should be the first "official" release after the initial announcement of the class in January 2015 via reddit ("0.1.0") and a heavily overworked second version ("0.2.0") in February.
### Changes
- *Changed:* In the generic class `basic_json`, all JSON value types (array, object, string, bool, integer number, and floating-point) are now **templated**. That is, you can choose whether you like a `std::list` for your arrays or an `std::unordered_map` for your objects. The specialization `json` sets some reasonable defaults.
- *Changed:* The library now consists of a **single header**, called `json.hpp`. Consequently, build systems such as Automake or CMake are not any longer required.
- *Changed:* The **deserialization** is now supported by a lexer generated with [re2c](http://re2c.org) from file [`src/json.hpp.re2c`](https://github.com/nlohmann/json/blob/master/src/json.hpp.re2c). As a result, we strictly follow the JSON specification. Note neither the tool re2c nor its input are required to use the class.
- *Added:* The library now satisfies the [**ReversibleContainer**](http://en.cppreference.com/w/cpp/concept/ReversibleContainer) requirement. It hence provides four different iterators (`iterator`, `const_iterator`, `reverse_iterator`, and `const_reverse_iterator`), comparison functions, `swap()`, `size()`, `max_size()`, and `empty()` member functions.
- *Added*: The class uses **user-defined allocators** which default to `std::allocator`, but can be templated via parameter `Allocator`.
- *Added:* To simplify pretty-printing, the `std::setw` **stream manipulator** has been overloaded to set the desired indentation. Pretty-printing a JSON object `j` is as simple as `std::cout << std::setw(4) << j << '\n'`.
- *Changed*: The type `json::value_t::number` is now called `json::value_t::number_integer` to be more symmetric compared to `json::value_t::number_float`.
- *Added*: The documentation is generated with Doxygen and hosted at [nlohmann.github.io/json](http://nlohmann.github.io/json/). Every public member function is thoroughly described including an example which also can be [tried online](http://melpon.org/wandbox/permlink/GnGKwji06WeVonlI).
- *Added*: The class is heavily unit-tested (3341774 assertions) and has a [line coverage of 100%](https://coveralls.io/github/nlohmann/json). With every commit, the code is compiled with g++ 4.9, g++ 5.0, Clang 3.6 (thanks to [Travis CI](https://travis-ci.org/nlohmann/json)), and Microsoft Visual Studio 14 2015 (thanks to [AppVeyor](https://ci.appveyor.com/project/nlohmann/json)).

View File

@@ -5,7 +5,7 @@
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "JSON for Modern C++"
PROJECT_NUMBER = 1.0.0-rc1
PROJECT_NUMBER = 2.0.2
PROJECT_BRIEF =
PROJECT_LOGO =
OUTPUT_DIRECTORY = .
@@ -30,6 +30,7 @@ TAB_SIZE = 4
ALIASES = "complexity=@par Complexity\n"
ALIASES += liveexample{2}="@par Example\n \1 \n @includelineno \2.cpp \n Output (play with this example @htmlinclude \2.link):\n @verbinclude \2.output \n The example code above can be translated with @verbatim g++ -std=c++11 -Isrc doc/examples/\2.cpp -o \2 @endverbatim"
ALIASES += requirement="@par Requirements\n"
ALIASES += exceptionsafety="@par Exception safety\n"
TCL_SUBST =
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = NO
@@ -101,7 +102,7 @@ WARN_LOGFILE =
#---------------------------------------------------------------------------
# Configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = ../src/json.hpp
INPUT = ../src/json.hpp index.md
INPUT_ENCODING = UTF-8
FILE_PATTERNS =
RECURSIVE = NO
@@ -117,7 +118,7 @@ INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
FILTER_SOURCE_PATTERNS =
USE_MDFILE_AS_MAINPAGE =
USE_MDFILE_AS_MAINPAGE = index.md
#---------------------------------------------------------------------------
# Configuration options related to source browsing
#---------------------------------------------------------------------------
@@ -235,7 +236,7 @@ MAN_LINKS = NO
#---------------------------------------------------------------------------
# Configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
GENERATE_XML = YES
XML_OUTPUT = xml
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------

View File

@@ -1,10 +1,8 @@
SRCDIR = ../src
SED:=$(shell command -v gsed || which sed)
all: doxygen
clean:
rm -fr me.nlohmann.json.docset html
##########################################################################
# example files
@@ -44,6 +42,10 @@ create_links: $(EXAMPLES:.cpp=.link)
check_output: $(EXAMPLES:.cpp=.test)
clean:
rm -fr me.nlohmann.json.docset html $(EXAMPLES:.cpp=)
##########################################################################
# Doxygen HTML documentation
##########################################################################
@@ -51,8 +53,10 @@ check_output: $(EXAMPLES:.cpp=.test)
# create Doxygen documentation
doxygen: create_output create_links
doxygen
gsed -i 's@&lt; ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, AllocatorType &gt;@@g' html/*.html
gsed -i 's@&lt;&#160;ObjectType,&#160;ArrayType,&#160;StringType,&#160;BooleanType,&#160;NumberIntegerType,&#160;NumberFloatType,&#160;AllocatorType&#160;&gt;@@g' html/*.html
$(SED) -i 's@&lt; ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, AllocatorType &gt;@@g' html/*.html
$(SED) -i 's@&lt;&#160;ObjectType,&#160;ArrayType,&#160;StringType,&#160;BooleanType,&#160;NumberIntegerType,&#160;NumberFloatType,&#160;AllocatorType&#160;&gt;@@g' html/*.html
$(SED) -i 's@&lt; ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType &gt;@@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
@@ -67,14 +71,14 @@ upload: clean doxygen check_output
# create docset for Dash
docset: create_output
cp Doxyfile Doxyfile_docset
gsed -i 's/DISABLE_INDEX = NO/DISABLE_INDEX = YES/' Doxyfile_docset
gsed -i 's/SEARCHENGINE = YES/SEARCHENGINE = NO/' Doxyfile_docset
gsed -i 's@HTML_EXTRA_STYLESHEET = css/mylayout.css@HTML_EXTRA_STYLESHEET = css/mylayout_docset.css@' Doxyfile_docset
$(SED) -i 's/DISABLE_INDEX = NO/DISABLE_INDEX = YES/' Doxyfile_docset
$(SED) -i 's/SEARCHENGINE = YES/SEARCHENGINE = NO/' Doxyfile_docset
$(SED) -i 's@HTML_EXTRA_STYLESHEET = css/mylayout.css@HTML_EXTRA_STYLESHEET = css/mylayout_docset.css@' Doxyfile_docset
rm -fr html *.docset
doxygen Doxyfile_docset
gsed -i 's@&lt; ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, AllocatorType &gt;@@g' html/*.html
gsed -i 's@&lt;&#160;ObjectType,&#160;ArrayType,&#160;StringType,&#160;BooleanType,&#160;NumberIntegerType,&#160;NumberFloatType,&#160;AllocatorType&#160;&gt;@@g' html/*.html
$(SED) -i 's@&lt; ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, AllocatorType &gt;@@g' html/*.html
$(SED) -i 's@&lt;&#160;ObjectType,&#160;ArrayType,&#160;StringType,&#160;BooleanType,&#160;NumberIntegerType,&#160;NumberFloatType,&#160;AllocatorType&#160;&gt;@@g' html/*.html
make -C html
mv html/*.docset .
gsed -i 's@<string>doxygen</string>@<string>json</string>@' me.nlohmann.json.docset/Contents/Info.plist
$(SED) -i 's@<string>doxygen</string>@<string>json</string>@' me.nlohmann.json.docset/Contents/Info.plist
rm -fr Doxyfile_docset html

View File

@@ -12,3 +12,15 @@ pre.fragment {
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
td.paramname {
vertical-align: top;
}
.ok_green {
background-color: #89C35C;
}
.nok_throws {
background-color: #ffa500;
}

View File

@@ -13,3 +13,15 @@
#top, .footer {
display: none;
}
td.paramname {
vertical-align: top;
}
.ok_green {
background-color: #89C35C;
}
.nok_throws {
background-color: #ffa500;
}

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/GnGKwji06WeVonlI"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/p5o4znPnGHJpDVqN"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/NeN8wmHsQGxFXC6L"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/1fsm4gI55p83DOwU"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/3ir8W1OZ5KtbRz6r"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/rsnwWxpDjmtRRSzb"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/zwOKkXrKstDlMPjr"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/aeoZrnhnb3HKClCY"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/9Ae4DO4HJjULnq5j"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/R7z2SB2rMdFQ9XtR"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/Ti47m4DY2lV4SWNV"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/L1bMeiN6nYm7JrvA"><b>online</b></a>

View File

@@ -0,0 +1,35 @@
#include <json.hpp>
using json = nlohmann::json;
int main()
{
// create a JSON value
json j =
{
{"number", 1}, {"string", "foo"}, {"array", {1, 2}}
};
// read-only access
// output element with JSON pointer "/number"
std::cout << j.at("/number"_json_pointer) << '\n';
// output element with JSON pointer "/string"
std::cout << j.at("/string"_json_pointer) << '\n';
// output element with JSON pointer "/array"
std::cout << j.at("/array"_json_pointer) << '\n';
// output element with JSON pointer "/array/1"
std::cout << j.at("/array/1"_json_pointer) << '\n';
// writing access
// change the string
j.at("/string"_json_pointer) = "bar";
// output the changed string
std::cout << j["string"] << '\n';
// change an array element
j.at("/array/1"_json_pointer) = 21;
// output the changed array
std::cout << j["array"] << '\n';
}

View File

@@ -0,0 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/NDSjglHZIjIZ0Uxg"><b>online</b></a>

View File

@@ -0,0 +1,6 @@
1
"foo"
[1,2]
2
"bar"
[1,21]

View File

@@ -0,0 +1,23 @@
#include <json.hpp>
using json = nlohmann::json;
int main()
{
// create a JSON value
json j =
{
{"number", 1}, {"string", "foo"}, {"array", {1, 2}}
};
// read-only access
// output element with JSON pointer "/number"
std::cout << j.at("/number"_json_pointer) << '\n';
// output element with JSON pointer "/string"
std::cout << j.at("/string"_json_pointer) << '\n';
// output element with JSON pointer "/array"
std::cout << j.at("/array"_json_pointer) << '\n';
// output element with JSON pointer "/array/1"
std::cout << j.at("/array/1"_json_pointer) << '\n';
}

View File

@@ -0,0 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/OuLYiMJ3pgyOHupb"><b>online</b></a>

View File

@@ -0,0 +1,4 @@
1
"foo"
[1,2]
2

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{
@@ -21,8 +21,8 @@ int main()
std::cout << j_number_integer.back() << '\n';
std::cout << j_number_float.back() << '\n';
std::cout << j_object.back() << '\n';
//std::cout << j_object_empty.back() << '\n'; // would throw
//std::cout << j_object_empty.back() << '\n'; // undefined behavior
std::cout << j_array.back() << '\n';
//std::cout << j_array_empty.back() << '\n'; // would throw
//std::cout << j_array_empty.back() << '\n'; // undefined behavior
std::cout << j_string.back() << '\n';
}

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/zB9tSkSVYIthfgj6"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/nPVnBcHf8nrNpGOJ"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/Hrajl95QUa1Lplou"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/dRptmFmhvpsYB49t"><b>online</b></a>

View File

@@ -5,7 +5,7 @@
#include <set>
#include <unordered_set>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/vyrjruntW4ASDBKH"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/MghSilgvyh4ZJShY"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/cyithYO7sPbXxK16"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/PcMzhcu2RpD7KSwr"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/yO6SWuP9bEYvNEvX"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/2TCYWSrOxnR05AZI"><b>online</b></a>

View File

@@ -1,7 +1,7 @@
#include <json.hpp>
#include <unordered_map>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/FCiYtNwovQ84DWxl"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/JzLCMcSXNsh4uVWa"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/h8c1hfORMnVrJ1Ky"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/b9hbCY8zfOiTOuoK"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/z2P1DpA8uSSlwgTl"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/nKF1QcieoCHm6Lez"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/vwVgsv7w6YZUgctJ"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/dTbSNAvl6TqrMEAn"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/wwzBU7cK8Xr2yiKJ"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/6Qfn12BDzb3vqO5p"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/RzWnqhbfuvbHXCBJ"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/VmVl9pyrQp8LyOnU"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/BPk4vUc4kJPWX0rz"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/3xQ1qy7BT9OrSSCo"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/P8QWpucrWhov8JRR"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/iWYvmlA4qQmtvACX"><b>online</b></a>

View File

@@ -0,0 +1,55 @@
#include <json.hpp>
using json = nlohmann::json;
int main()
{
// a JSON text
auto 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]
}
}
)";
// fill a stream with JSON text
std::stringstream ss;
ss << text;
// create JSON from stream
json j_complete(ss);
std::cout << std::setw(4) << j_complete << "\n\n";
// define parser callback
json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed)
{
// skip object elements with key "Thumbnail"
if (event == json::parse_event_t::key and parsed == json("Thumbnail"))
{
return false;
}
else
{
return true;
}
};
// fill a stream with JSON text
ss.clear();
ss << text;
// create JSON from stream (with callback)
json j_filtered(ss, cb);
std::cout << std::setw(4) << j_filtered << '\n';
}

View File

@@ -0,0 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/VzSqLszbnoWE92dD"><b>online</b></a>

View File

@@ -0,0 +1,34 @@
{
"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
}
}
{
"Image": {
"Animated": false,
"Height": 600,
"IDs": [
116,
943,
234,
38793
],
"Title": "View from 15th Floor",
"Width": 800
}
}

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/IWIZSNthuHrT3AS6"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/iZzzxEpB7tbhz0cx"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/dvTtz7DIo8TDhYE6"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/CaDlatv1uXhQiu7o"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/hcERmrPzjmXeSzB8"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/PMMpoM0ujdJDsuta"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/47cqX7AduSWn24lA"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/OTgOxjIAKFvxpFdm"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/RUSNdk5YEAr2vL4E"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/cCQRCvjXdRM9YpT5"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/4IF0ofRq0nZcV8pI"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/DgtHcz5L6JphTOGJ"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/dkznQmTMqulurCqD"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/IFZT4VL0oRotJBxl"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/S9jwK28ThNIGkdUI"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/cwNYP1q2mT8CFLTk"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/xNtouqvB2OJBOwkv"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/AtV4zVErfLwkileg"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/pehnjdIduvv90qfX"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/qdV5W2Lrljmjv4LG"><b>online</b></a>

View File

@@ -0,0 +1,29 @@
#include <json.hpp>
using json = nlohmann::json;
int main()
{
// create a JSON object with different entry types
json j =
{
{"integer", 1},
{"floating", 42.23},
{"string", "hello world"},
{"boolean", true},
{"object", {{"key1", 1}, {"key2", 2}}},
{"array", {1, 2, 3}}
};
// access existing values
int v_integer = j.value("/integer"_json_pointer, 0);
double v_floating = j.value("/floating"_json_pointer, 47.11);
// access nonexisting values and rely on default value
std::string v_string = j.value("/nonexisting"_json_pointer, "oops");
bool v_boolean = j.value("/nonexisting"_json_pointer, false);
// output values
std::cout << std::boolalpha << v_integer << " " << v_floating
<< " " << v_string << " " << v_boolean << "\n";
}

View File

@@ -0,0 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/K4L4D6nibuGXbjfd"><b>online</b></a>

View File

@@ -0,0 +1 @@
1 42.23 oops false

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/ncOG8fdxNrISUNFj"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/RMpEI2o935KgD2o2"><b>online</b></a>

View File

@@ -1,7 +1,7 @@
null
false
0
0
0.0
{}
[]
""

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/Nwb94PEGlvnjrqj1"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/0lW1WJ1ZP8g92Jp9"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/mWrMi5IrJjRILgir"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/yarD6DyxYlIf8Ymg"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/0OHrFwFGvRuDKdfx"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/9oPbpnFNgKtKjB0O"><b>online</b></a>

View File

@@ -1,6 +1,6 @@
#include <json.hpp>
using namespace nlohmann;
using json = nlohmann::json;
int main()
{

View File

@@ -1 +1 @@
<a target="_blank" href="http://melpon.org/wandbox/permlink/Ddggfbg18WXOIBkW"><b>online</b></a>
<a target="_blank" href="http://melpon.org/wandbox/permlink/wwsjMZP8U6bWhUil"><b>online</b></a>

View File

@@ -1,7 +1,7 @@
null
false
0
0
0.0
{}
[]
""

Some files were not shown because too many files have changed in this diff Show More