Skip to content

Commit

Permalink
🔀 merge branch 'release/2.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
nlohmann committed Feb 25, 2017
2 parents 1e99a02 + 27c65b8 commit c0d511e
Show file tree
Hide file tree
Showing 62 changed files with 6,657 additions and 1,319 deletions.
24 changes: 0 additions & 24 deletions .doozer.json

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ fuzz-testing
*.gcno
*.gcda

build
working

doc/xml
Expand Down
13 changes: 12 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,14 @@ install:
# make sure CXX is correctly set
- if [[ "${COMPILER}" != "" ]]; then export CXX=${COMPILER}; fi

# get CMake (only for systems with brew - macOS)
- |
if [[ !(-x $(which cmake)) && (-x $(which brew)) ]]; then
brew update
brew install cmake
cmake --version
fi
# install LLVM/clang when LLVM_VERSION is set
- |
if [[ "${LLVM_VERSION}" != "" ]]; then
Expand Down Expand Up @@ -266,7 +274,10 @@ script:
- $CXX --version

# compile and execute unit tests
- make check
- mkdir -p build && cd build
- cmake .. && cmake --build . --config Release -- -j4
- ctest -C Release -V
- cd ..

# check if homebrew works (only checks develop branch)
- if [ `which brew` ]; then
Expand Down
20 changes: 11 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.0)

# define the project
project(nlohmann_json VERSION 2.1.0 LANGUAGES CXX)
project(nlohmann_json VERSION 2.1.1 LANGUAGES CXX)

enable_testing()

Expand All @@ -16,14 +16,16 @@ set(JSON_CONFIGVERSION_FILENAME "${JSON_PACKAGE_NAME}ConfigVersion.cmake")
set(JSON_CONFIG_DESTINATION "cmake")
set(JSON_INCLUDE_DESTINATION "include/nlohmann")

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

# 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}>)

# create and configure the unit test target
if (BuildTests)
if(BuildTests)
add_subdirectory(test)
endif()

Expand All @@ -39,17 +41,17 @@ write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/${JSON_CONFIGVERSI

# export the library target and store build directory in package registry
export(TARGETS ${JSON_TARGET_NAME}
FILE "${CMAKE_CURRENT_BINARY_DIR}/${JSON_TARGETS_FILENAME}")
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})
EXPORT ${JSON_PACKAGE_NAME})
install(FILES "src/json.hpp"
DESTINATION ${JSON_INCLUDE_DESTINATION})
DESTINATION ${JSON_INCLUDE_DESTINATION})
install(EXPORT ${JSON_PACKAGE_NAME}
FILE ${JSON_TARGETS_FILENAME}
DESTINATION ${JSON_CONFIG_DESTINATION})
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})
"${CMAKE_CURRENT_BINARY_DIR}/${JSON_CONFIGVERSION_FILENAME}"
DESTINATION ${JSON_CONFIG_DESTINATION})
36 changes: 36 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@
# Change Log
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).

## [v2.1.1](/~https://github.com/nlohmann/json/releases/tag/v2.1.1) (2017-02-25)
[Full Changelog](/~https://github.com/nlohmann/json/compare/v2.1.0...v2.1.1)

- warning in the library [\#472](/~https://github.com/nlohmann/json/issues/472)
- How to create an array of Objects? [\#470](/~https://github.com/nlohmann/json/issues/470)
- \[Bug?\] Cannot get int pointer, but int64\_t works [\#468](/~https://github.com/nlohmann/json/issues/468)
- Illegal indirection [\#467](/~https://github.com/nlohmann/json/issues/467)
- in vs can't find linkageId [\#466](/~https://github.com/nlohmann/json/issues/466)
- Roundtrip error while parsing "1000000000000000010E5" [\#465](/~https://github.com/nlohmann/json/issues/465)
- C4996 error and warning with Visual Studio [\#463](/~https://github.com/nlohmann/json/issues/463)
- Support startIndex for from\_cbor/from\_msgpack [\#462](/~https://github.com/nlohmann/json/issues/462)
- question: monospace font used in feature slideshow? [\#460](/~https://github.com/nlohmann/json/issues/460)
- Object.keys\(\) [\#459](/~https://github.com/nlohmann/json/issues/459)
- Use “, “ as delimiter for json-objects. [\#457](/~https://github.com/nlohmann/json/issues/457)
- Enum -\> string during serialization and vice versa [\#455](/~https://github.com/nlohmann/json/issues/455)
- doubles are printed as integers [\#454](/~https://github.com/nlohmann/json/issues/454)
- Warnings with Visual Studio c++ \(VS2015 Update 3\) [\#453](/~https://github.com/nlohmann/json/issues/453)
- Heap-buffer-overflow \(OSS-Fuzz issue 585\) [\#452](/~https://github.com/nlohmann/json/issues/452)
- use of undeclared identifier 'UINT8\_MAX' [\#451](/~https://github.com/nlohmann/json/issues/451)
- Question on the lifetime managment of objects at the lower levels [\#449](/~https://github.com/nlohmann/json/issues/449)
- Json should not be constructible with 'json\*' [\#448](/~https://github.com/nlohmann/json/issues/448)
- Move value\_t to namespace scope [\#447](/~https://github.com/nlohmann/json/issues/447)
- Typo in README.md [\#446](/~https://github.com/nlohmann/json/issues/446)
- make check compilation is unneccesarily slow [\#445](/~https://github.com/nlohmann/json/issues/445)
- Problem in dump\(\) in json.h caused by ss.imbue [\#444](/~https://github.com/nlohmann/json/issues/444)
- I want to create Windows Application in Visual Studio 2015 c++, and i have a problem [\#443](/~https://github.com/nlohmann/json/issues/443)
- Implicit conversion issues [\#442](/~https://github.com/nlohmann/json/issues/442)
- Parsing of floats locale dependent [\#302](/~https://github.com/nlohmann/json/issues/302)

- Speedup CI builds using cotire [\#461](/~https://github.com/nlohmann/json/pull/461) ([tusharpm](/~https://github.com/tusharpm))
- TurpentineDistillery feature/locale independent str to num [\#450](/~https://github.com/nlohmann/json/pull/450) ([nlohmann](/~https://github.com/nlohmann))
- README: adjust boost::optional example [\#439](/~https://github.com/nlohmann/json/pull/439) ([jaredgrubb](/~https://github.com/jaredgrubb))
- fix \#414 - comparing to 0 literal [\#415](/~https://github.com/nlohmann/json/pull/415) ([stanmihai4](/~https://github.com/stanmihai4))

## [v2.1.0](/~https://github.com/nlohmann/json/releases/tag/v2.1.0) (2017-01-28)
[Full Changelog](/~https://github.com/nlohmann/json/compare/v2.0.10...v2.1.0)

Expand All @@ -20,6 +54,7 @@ All notable changes to this project will be documented in this file. This projec
- size parameter for parse\(\) [\#419](/~https://github.com/nlohmann/json/issues/419)
- json.hpp forcibly defines GCC\_VERSION [\#417](/~https://github.com/nlohmann/json/issues/417)
- Use-of-uninitialized-value \(OSS-Fuzz issue 377\) [\#416](/~https://github.com/nlohmann/json/issues/416)
- comparing to 0 literal [\#414](/~https://github.com/nlohmann/json/issues/414)
- Single char converted to ASCII code instead of string [\#413](/~https://github.com/nlohmann/json/issues/413)
- How to know if a string was parsed as utf-8? [\#406](/~https://github.com/nlohmann/json/issues/406)
- Overloaded += to add objects to an array makes no sense? [\#404](/~https://github.com/nlohmann/json/issues/404)
Expand All @@ -37,6 +72,7 @@ All notable changes to this project will be documented in this file. This projec

- conversion from/to user-defined types [\#435](/~https://github.com/nlohmann/json/pull/435) ([nlohmann](/~https://github.com/nlohmann))
- Fix documentation error [\#430](/~https://github.com/nlohmann/json/pull/430) ([vjon](/~https://github.com/vjon))
- locale-independent num-to-str [\#378](/~https://github.com/nlohmann/json/pull/378) ([TurpentineDistillery](/~https://github.com/TurpentineDistillery))

## [v2.0.10](/~https://github.com/nlohmann/json/releases/tag/v2.0.10) (2017-01-02)
[Full Changelog](/~https://github.com/nlohmann/json/compare/v2.0.9...v2.0.10)
Expand Down
24 changes: 23 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,28 @@ doctest:
$(MAKE) check_output -C doc


##########################################################################
# warning detector
##########################################################################

# calling Clang with all warnings, except:
# -Wno-documentation-unknown-command: code uses user-defined commands like @complexity
# -Wno-exit-time-destructors: warning in Catch code
# -Wno-keyword-macro: unit-tests use "#define private public"
# -Wno-deprecated-declarations: some functions are deprecated until 3.0.0
# -Wno-range-loop-analysis: iterator_wrapper tests tests "for(const auto i...)"
pedantic:
$(MAKE) json_unit CXXFLAGS="\
-std=c++11 \
-Werror \
-Weverything \
-Wno-documentation-unknown-command \
-Wno-exit-time-destructors \
-Wno-keyword-macro \
-Wno-deprecated-declarations \
-Wno-range-loop-analysis"


##########################################################################
# fuzzing
##########################################################################
Expand Down Expand Up @@ -94,7 +116,7 @@ cppcheck:

# run clang sanitize (we are overrding the CXXFLAGS provided by travis in order to use gcc's libstdc++)
clang_sanitize: clean
CXX=clang++ CXXFLAGS="-g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer" $(MAKE)
CXX=clang++ CXXFLAGS="-g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer" $(MAKE) check


##########################################################################
Expand Down
59 changes: 54 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

[![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/branch/develop?svg=true)](https://ci.appveyor.com/project/nlohmann/json)
[![Build status](https://doozer.io/badge/nlohmann/json/buildstatus/develop)](https://doozer.io/user/nlohmann/json)
[![Coverage Status](https://img.shields.io/coveralls/nlohmann/json.svg)](https://coveralls.io/r/nlohmann/json)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/5550/badge.svg)](https://scan.coverity.com/projects/nlohmann-json)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/f3732b3327e34358a0e9d1fe9f661f08)](https://www.codacy.com/app/nlohmann/json?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=nlohmann/json&amp;utm_campaign=Badge_Grade)
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](http://melpon.org/wandbox/permlink/4NEU6ZZMoM9lpIex)
[![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)
Expand All @@ -26,6 +26,8 @@
- [Supported compilers](#supported-compilers)
- [License](#license)
- [Thanks](#thanks)
- [Used third-party tools](#used-third-party-tools)
- [Projects using JSON for Modern C++](#projects-using-json-for-modern-c)
- [Notes](#notes)
- [Execute unit tests](#execute-unit-tests)

Expand Down Expand Up @@ -167,8 +169,14 @@ auto j2 = R"(
"pi": 3.141
}
)"_json;
```

Note that without appending the `_json` suffix, the passed string literal is not parsed, but just used as JSON string value. That is, `json j = "{ \"happy\": true, \"pi\": 3.141 }"` would just store the string `"{ "happy": true, "pi": 3.141 }"` rather than parsing the actual object.

The above example can also be expressed explicitly using `json::parse()`:

// or explicitly
```cpp
// parse explicitly
auto j3 = json::parse("{ \"happy\": true, \"pi\": 3.141 }");
```

Expand Down Expand Up @@ -563,7 +571,9 @@ namespace nlohmann {
}

static void from_json(const json& j, boost::optional<T>& opt) {
if (!j.is_null()) {
if (j.is_null()) {
opt = boost::none;
} else {
opt = j.get<T>(); // same as above, but with
// adl_serializer<T>::from_json
}
Expand Down Expand Up @@ -800,7 +810,7 @@ I deeply appreciate the help of the following people.
- [Vladimir Petrigo](/~https://github.com/vpetrigo) made a SFINAE hack more readable.
- [Denis Andrejew](/~https://github.com/seeekr) fixed a grammar issue in the README file.
- [Pierre-Antoine Lacaze](/~https://github.com/palacaze) found a subtle bug in the `dump()` function.
- [TurpentineDistillery](/~https://github.com/TurpentineDistillery) pointed to [`std::locale::classic()`](http://en.cppreference.com/w/cpp/locale/locale/classic) to avoid too much locale joggling, found some nice performance improvements in the parser and improved the benchmarking code.
- [TurpentineDistillery](/~https://github.com/TurpentineDistillery) pointed to [`std::locale::classic()`](http://en.cppreference.com/w/cpp/locale/locale/classic) to avoid too much locale joggling, found some nice performance improvements in the parser, improved the benchmarking code, and realized locale-independent number parsing and printing.
- [cgzones](/~https://github.com/cgzones) had an idea how to fix the Coverity scan.
- [Jared Grubb](/~https://github.com/jaredgrubb) silenced a nasty documentation warning.
- [Yixin Zhang](/~https://github.com/qwename) fixed an integer overflow check.
Expand All @@ -811,10 +821,49 @@ I deeply appreciate the help of the following people.
- [Alexej Harm](/~https://github.com/qis) helped to get the user-defined types working with Visual Studio.
- [Jared Grubb](/~https://github.com/jaredgrubb) supported the implementation of user-defined types.
- [EnricoBilla](/~https://github.com/EnricoBilla) noted a typo in an example.
- [Martin Hořeňovský](/~https://github.com/horenmar) found a way for a 2x speedup for the compilation time of the test suite.
- [ukhegg](/~https://github.com/ukhegg) found proposed an improvement for the examples section.
- [rswanson-ihi](/~https://github.com/rswanson-ihi) noted a type in the README.
- [Mihai Stan](/~https://github.com/stanmihai4) fixed a bug in the comparison with `nullptr`s.
- [Tushar Maheshwari](/~https://github.com/tusharpm) added [cotire](/~https://github.com/sakra/cotire) support to speed up the compilation.
Thanks a lot for helping out! Please [let me know](mailto:mail@nlohmann.me) if I forgot someone.
## Used third-party tools
The library itself contains of a single header file licensed under the MIT license. However, it is built, tested, documented, and whatnot using a lot of thirs-party tools and services. Thanks a lot!
- [**American fuzzy lop**](http://lcamtuf.coredump.cx/afl/) for fuzz testing
- [**AppVeyor**](https://www.appveyor.com) for [continuous integration](https://ci.appveyor.com/project/nlohmann/json) on Windows
- [**Artistic Style**](http://astyle.sourceforge.net) for automatic source code identation
- [**benchpress**](/~https://github.com/sbs-ableton/benchpress) to benchmark the code
- [**Catch**](/~https://github.com/philsquared/Catch) for the unit tests
- [**Clang**](http://clang.llvm.org) for compilation with code sanitizers
- [**Cmake**](https://cmake.org) for build automation
- [**Codacity**](https://www.codacy.com) for further [code analysis](https://www.codacy.com/app/nlohmann/json)
- [**cotire**](/~https://github.com/sakra/cotire) to speed of compilation
- [**Coveralls**](https://coveralls.io) to measure [code coverage](https://coveralls.io/github/nlohmann/json)
- [**Coverity Scan**](https://scan.coverity.com) for [static analysis](https://scan.coverity.com/projects/nlohmann-json)
- [**cppcheck**](http://cppcheck.sourceforge.net) for static analysis
- [**cxxopts**](/~https://github.com/jarro2783/cxxopts) to let benchpress parse command-line parameters
- [**Doxygen**](http://www.stack.nl/~dimitri/doxygen/) to generate [documentation](https://nlohmann.github.io/json/)
- [**git-update-ghpages**](/~https://github.com/rstacruz/git-update-ghpages) to upload the documentation to gh-pages
- [**Github Changelog Generator**](/~https://github.com/skywinder/github-changelog-generator) to generate the [ChangeLog](/~https://github.com/nlohmann/json/blob/develop/ChangeLog.md)
- [**libFuzzer**](http://llvm.org/docs/LibFuzzer.html) to implement fuzz testing for OSS-Fuzz
- [**OSS-Fuzz**](/~https://github.com/google/oss-fuzz) for continuous fuzz testing of the library
- [**re2c**](http://re2c.org) to generate an automaton for the lexical analysis
- [**send_to_wandbox**](/~https://github.com/nlohmann/json/blob/develop/doc/scripts/send_to_wandbox.py) to send code examples to [Wandbox](http://melpon.org/wandbox)
- [**Travis**](https://travis-ci.org) for [continuous integration](https://travis-ci.org/nlohmann/json) on Linux and macOS
- [**Valgrind**](http://valgrind.org) to check for correct memory management
- [**Wandbox**](http://melpon.org/wandbox) for [online examples](http://melpon.org/wandbox/permlink/4NEU6ZZMoM9lpIex)
## Projects using JSON for Modern C++
The library is currently used in Apple macOS Sierra and iOS 10. I am not sure what they are using the library for, but I am happy that it runs on so many devices.
## 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). In particular, note [`operator[]`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a2e26bd0b0168abb61f67ad5bcd5b9fa1.html#a2e26bd0b0168abb61f67ad5bcd5b9fa1) implements **unchecked access** for const objects: If the given key is not present, the behavior is undefined (think of a dereferenced null pointer) and yields an [assertion failure](/~https://github.com/nlohmann/json/issues/289) if assertions are switched on. If you are not sure whether an element in an object exists, use checked access with the [`at()` function](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a674de1ee73e6bf4843fc5dc1351fb726.html#a674de1ee73e6bf4843fc5dc1351fb726).
Expand All @@ -838,7 +887,7 @@ $ make json_unit -Ctest
$ ./test/json_unit "*""
===============================================================================
All tests passed (11202052 assertions in 47 test cases)
All tests passed (11202597 assertions in 47 test cases)
```

Alternatively, you can use [CMake](https://cmake.org) and run
Expand Down
20 changes: 10 additions & 10 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
version: '{build}'
os: Visual Studio 2015
init: []
install: []
build_script:
- set PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH%
- cmake . -G "Visual Studio 14 2015"
- cmake --build . --config Release
test_script:
- ctest -C Release -V
version: '{build}'
os: Visual Studio 2015
init: []
install: []
build_script:
- set PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH%
- cmake . -G "Visual Studio 14 2015"
- cmake --build . --config Release
test_script:
- ctest -C Release -V
Loading

0 comments on commit c0d511e

Please sign in to comment.