Merge branch 'release/2.0.7'

This commit is contained in:
Niels 2016-11-02 20:52:24 +01:00
commit a4d13c92ba
358 changed files with 1330 additions and 330 deletions

View file

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.0)
# define the project
project(nlohmann_json VERSION 2.0.6 LANGUAGES CXX)
project(nlohmann_json VERSION 2.0.7 LANGUAGES CXX)
enable_testing()

View file

@ -1,6 +1,15 @@
# 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.7](https://github.com/nlohmann/json/releases/tag/v2.0.7) (2016-11-02)
[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.6...v2.0.7)
- ""-operators ignore the length parameter [\#340](https://github.com/nlohmann/json/issues/340)
- Check "Parsing JSON is a Minefield" [\#344](https://github.com/nlohmann/json/issues/344)
- fix minor grammar/style issue in README.md [\#336](https://github.com/nlohmann/json/pull/336) ([seeekr](https://github.com/seeekr))
## [v2.0.6](https://github.com/nlohmann/json/releases/tag/v2.0.6) (2016-10-15)
[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.5...v2.0.6)
@ -143,7 +152,6 @@ All notable changes to this project will be documented in this file. This projec
- 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)

View file

@ -75,7 +75,7 @@ clang_sanitize: clean
# create scanner with re2c
re2c: src/json.hpp.re2c
$(RE2C) -W --bit-vectors --nested-ifs --no-debug-info $< | $(SED) '1d' > src/json.hpp
$(RE2C) -W --utf-8 --encoding-policy fail --bit-vectors --nested-ifs --no-debug-info $< | $(SED) '1d' > src/json.hpp
# pretty printer
pretty:

View file

@ -3,7 +3,7 @@
[![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)
[![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/3BIhBw91FUVuHE1D)
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](http://melpon.org/wandbox/permlink/fsf5FqYe6GoX68W6)
[![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)
@ -14,7 +14,7 @@
There are myriads of [JSON](http://json.org) libraries out there, and each may even have its reason to exist. Our class had these design goals:
- **Intuitive syntax**. In languages such as Python, JSON feels like a first class data type. We used all the operator magic of modern C++ to achieve the same feeling in your code. Check out the [examples below](#examples) and you know, what I mean.
- **Intuitive syntax**. In languages such as Python, JSON feels like a first class data type. We used all the operator magic of modern C++ to achieve the same feeling in your code. Check out the [examples below](#examples) and you'll know what I mean.
- **Trivial integration**. Our whole code consists of a single header file [`json.hpp`](https://github.com/nlohmann/json/blob/develop/src/json.hpp). That's it. No library, no subproject, no dependencies, no complex build system. The class is written in vanilla C++11. All in all, everything should require no adjustment of your compiler flags or project settings.
@ -498,6 +498,7 @@ I deeply appreciate the help of the following people.
- [Vasil Dimov](https://github.com/vasild) fixed the documentation regarding conversions from `std::multiset`.
- [ChristophJud](https://github.com/ChristophJud) overworked the CMake files to ease project inclusion.
- [Vladimir Petrigo](https://github.com/vpetrigo) made a SFINAE hack more readable.
- [Denis Andrejew](https://github.com/seeekr) fixed a grammar issue in the README file.
Thanks a lot for helping out!
@ -506,6 +507,11 @@ Thanks a lot for helping out!
- The code contains numerous debug **assertions** which can be switched off by defining the preprocessor macro `NDEBUG`, see the [documentation of `assert`](http://en.cppreference.com/w/cpp/error/assert). In particular, note [`operator[]`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a2e26bd0b0168abb61f67ad5bcd5b9fa1.html#a2e26bd0b0168abb61f67ad5bcd5b9fa1) implements **unchecked access** for const objects: If the given key is not present, the behavior is undefined (think of a dereferenced null pointer) and yields an [assertion failure](https://github.com/nlohmann/json/issues/289) if assertions are switched on. If you are not sure whether an element in an object exists, use checked access with the [`at()` function](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a674de1ee73e6bf4843fc5dc1351fb726.html#a674de1ee73e6bf4843fc5dc1351fb726).
- As the exact type of a number is not defined in the [JSON specification](http://rfc7159.net/rfc7159), this library tries to choose the best fitting C++ number type automatically. As a result, the type `double` may be used to store numbers which may yield [**floating-point exceptions**](https://github.com/nlohmann/json/issues/181) in certain rare situations if floating-point exceptions have been unmasked in the calling code. These exceptions are not caused by the library and need to be fixed in the calling code, such as by re-masking the exceptions prior to calling library functions.
- The library supports **Unicode input** as follows:
- Only **UTF-8** encoded input is supported which is the default encoding for JSON according to [RFC 7159](http://rfc7159.net/rfc7159#rfc.section.8.1).
- Other encodings such as Latin-1, UTF-16, or UTF-32 are not supported and will yield parse errors.
- [Unicode noncharacters](http://www.unicode.org/faq/private_use.html#nonchar1) will not be replaced by the library.
- Invalid surrogates (e.g., incomplete pairs such as `\uDEAD`) will yield parse errors.
## Execute unit tests
@ -516,10 +522,10 @@ To compile and run the tests, you need to execute
$ make check
===============================================================================
All tests passed (8905168 assertions in 35 test cases)
All tests passed (8905491 assertions in 36 test cases)
```
Alternatively, you can use [https://cmake.org](CMake) and run
Alternatively, you can use [CMake](https://cmake.org) and run
```sh
$ mkdir build

View file

@ -5,7 +5,7 @@
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "JSON for Modern C++"
PROJECT_NUMBER = 2.0.6
PROJECT_NUMBER = 2.0.7
PROJECT_BRIEF =
PROJECT_LOGO =
OUTPUT_DIRECTORY = .

View file

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

View file

@ -268,4 +268,4 @@ The container functions known from STL have been extended to support the differe
@author [Niels Lohmann](http://nlohmann.me)
@see https://github.com/nlohmann/json to download the source code
@version 2.0.6
@version 2.0.7

Binary file not shown.

Before

Width:  |  Height:  |  Size: 439 KiB

After

Width:  |  Height:  |  Size: 444 KiB

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
/*
__ _____ _____ _____
__| | __| | | | JSON for Modern C++
| | |__ | | | | | | version 2.0.6
| | |__ | | | | | | version 2.0.7
|_____|_____|_____|_|___| https://github.com/nlohmann/json
Licensed under the MIT License <http://opensource.org/licenses/MIT>.
@ -7620,6 +7620,14 @@ class basic_json
{
// fill buffer
fill_line_buffer();
// skip UTF-8 byte-order mark
if (m_line_buffer.size() >= 3 and m_line_buffer.substr(0, 3) == "\xEF\xBB\xBF")
{
m_line_buffer[0] = ' ';
m_line_buffer[1] = ' ';
m_line_buffer[2] = ' ';
}
}
// switch off unwanted functions (due to pointer members)
@ -7788,24 +7796,20 @@ class basic_json
assert(m_start != nullptr);
/*!re2c
re2c:define:YYCTYPE = lexer_char_t;
re2c:define:YYCURSOR = m_cursor;
re2c:define:YYLIMIT = m_limit;
re2c:define:YYMARKER = m_marker;
re2c:define:YYFILL = "fill_line_buffer()";
re2c:yyfill:parameter = 0;
re2c:indent:string = " ";
re2c:indent:top = 1;
re2c:labelprefix = "basic_json_parser_";
re2c:define:YYCTYPE = lexer_char_t;
re2c:define:YYCURSOR = m_cursor;
re2c:define:YYLIMIT = m_limit;
re2c:define:YYMARKER = m_marker;
re2c:define:YYFILL = "fill_line_buffer(@@); // LCOV_EXCL_LINE";
re2c:define:YYFILL:naked = 1;
re2c:indent:string = " ";
re2c:indent:top = 1;
re2c:labelprefix = "basic_json_parser_";
// ignore whitespace
ws = [ \t\n\r]+;
ws { continue; }
// ignore byte-order-mark
bom = "\xEF\xBB\xBF";
bom { continue; }
// structural characters
"[" { last_token_type = token_type::begin_array; break; }
"]" { last_token_type = token_type::end_array; break; }
@ -7845,10 +7849,10 @@ class basic_json
string { last_token_type = token_type::value_string; break; }
// end of file
"\000" { last_token_type = token_type::end_of_input; break; }
"\x00" { last_token_type = token_type::end_of_input; break; }
// anything else is an error
. { last_token_type = token_type::parse_error; break; }
* { last_token_type = token_type::parse_error; break; }
*/
}
@ -7883,7 +7887,7 @@ class basic_json
m_start
m_content
*/
void fill_line_buffer()
void fill_line_buffer(size_t n = 0)
{
// number of processed characters (p)
const auto offset_start = m_start - m_content;
@ -7895,17 +7899,21 @@ class basic_json
// no stream is used or end of file is reached
if (m_stream == nullptr or m_stream->eof())
{
// copy unprocessed characters to line buffer
m_line_buffer.clear();
for (m_cursor = m_start; m_cursor != m_limit; ++m_cursor)
// skip this part if we are already using the line buffer
if (m_start != reinterpret_cast<const lexer_char_t*>(m_line_buffer.data()))
{
m_line_buffer.append(1, static_cast<const char>(*m_cursor));
// copy unprocessed characters to line buffer
m_line_buffer.clear();
for (m_cursor = m_start; m_cursor != m_limit; ++m_cursor)
{
m_line_buffer.append(1, static_cast<const char>(*m_cursor));
}
}
// append 5 characters (size of longest keyword "false") to
// make sure that there is sufficient space between m_cursor
// and m_limit
m_line_buffer.append(5, '\0');
// append n characters to make sure that there is sufficient
// space between m_cursor and m_limit
m_line_buffer.append(1, '\x00');
m_line_buffer.append(n - 1, '\x01');
}
else
{
@ -7913,7 +7921,7 @@ class basic_json
m_line_buffer.erase(0, static_cast<size_t>(offset_start));
// read next line from input stream
std::string line;
std::getline(*m_stream, line);
std::getline(*m_stream, line, '\n');
// add line with newline symbol to the line buffer
m_line_buffer += line + "\n";
}
@ -8075,6 +8083,11 @@ class basic_json
// skip the next 10 characters (xxxx\uyyyy)
i += 10;
}
else if (codepoint >= 0xDC00 and codepoint <= 0xDFFF)
{
// we found a lone low surrogate
throw std::invalid_argument("missing high surrogate");
}
else
{
// add unicode character(s)
@ -8257,6 +8270,13 @@ class basic_json
{
// parse with strtod
result.m_value.number_float = str_to_float_t(static_cast<number_float_t*>(nullptr), NULL);
// replace infinity and NAN by null
if (not std::isfinite(result.m_value.number_float))
{
type = value_t::null;
result.m_value = basic_json::json_value();
}
}
// save the type
@ -9887,13 +9907,14 @@ can be used by adding `"_json"` to a string literal and returns a JSON object
if no parse error occurred.
@param[in] s a string representation of a JSON object
@param[in] n the length of string @a s
@return a JSON object
@since version 1.0.0
*/
inline nlohmann::json operator "" _json(const char* s, std::size_t)
inline nlohmann::json operator "" _json(const char* s, std::size_t n)
{
return nlohmann::json::parse(s);
return nlohmann::json::parse(s, s + n);
}
/*!
@ -9904,13 +9925,14 @@ can be used by adding `"_json_pointer"` to a string literal and returns a JSON p
object if no parse error occurred.
@param[in] s a string representation of a JSON Pointer
@param[in] n the length of string @a s
@return a JSON pointer object
@since version 2.0.0
*/
inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t)
inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n)
{
return nlohmann::json::json_pointer(s);
return nlohmann::json::json_pointer(std::string(s, n));
}
// restore GCC/clang diagnostic settings

View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2016 Nicolas Seriot
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.

View file

@ -0,0 +1 @@
[-1e+9999]

View file

@ -0,0 +1 @@
[1.5e+9999]

View file

@ -0,0 +1 @@
{"\uDFAA":0}

View file

@ -0,0 +1 @@
["\ud800abc"]

View file

@ -0,0 +1 @@
["譌・ム淫"]

View file

@ -0,0 +1 @@
["\uDd1ea"]

View file

@ -0,0 +1 @@
["\uD800\uD800\n"]

View file

@ -0,0 +1 @@
["\uDd1e\uD834"]

View file

@ -0,0 +1 @@
["<22><><EFBFBD><EFBFBD>"]

View file

@ -0,0 +1 @@
["<22><>"]

View file

@ -0,0 +1 @@
["\uDBFF\uDFFE"]

View file

@ -0,0 +1 @@
["\uD83F\uDFFE"]

View file

@ -0,0 +1 @@
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

View file

@ -0,0 +1 @@
[a

View file

@ -0,0 +1 @@
[,1]

View file

@ -0,0 +1 @@
[1,,2]

View file

@ -0,0 +1 @@
["x"]]

View file

@ -0,0 +1 @@
["",]

View file

@ -0,0 +1 @@
["x"

View file

@ -0,0 +1 @@
[<EFBFBD>]

View file

@ -0,0 +1 @@
[,]

View file

@ -0,0 +1 @@
[-]

View file

@ -0,0 +1 @@
[ , ""]

View file

@ -0,0 +1,3 @@
["a",
4
,1,

View file

@ -0,0 +1 @@
[1,]

View file

@ -0,0 +1 @@
[*]

View file

@ -0,0 +1 @@
[""

View file

@ -0,0 +1 @@
[fals]

View file

@ -0,0 +1 @@
[nul]

View file

@ -0,0 +1 @@
[tru]

View file

@ -0,0 +1 @@
[++1234]

View file

@ -0,0 +1 @@
[+1]

View file

@ -0,0 +1 @@
[+Inf]

View file

@ -0,0 +1 @@
[-01]

View file

@ -0,0 +1 @@
[-1.0.]

View file

@ -0,0 +1 @@
[-2.]

View file

@ -0,0 +1 @@
[-NaN]

View file

@ -0,0 +1 @@
[.-1]

View file

@ -0,0 +1 @@
[.2e-3]

View file

@ -0,0 +1 @@
[0.1.2]

View file

@ -0,0 +1 @@
[0.3e+]

View file

@ -0,0 +1 @@
[0.3e]

View file

@ -0,0 +1 @@
[0.e1]

View file

@ -0,0 +1 @@
[0E+]

View file

@ -0,0 +1 @@
[0E]

View file

@ -0,0 +1 @@
[0e+]

View file

@ -0,0 +1 @@
[0e]

View file

@ -0,0 +1 @@
[1.0e+]

View file

@ -0,0 +1 @@
[1.0e-]

View file

@ -0,0 +1 @@
[1.0e]

View file

@ -0,0 +1 @@
[1 000.0]

View file

@ -0,0 +1 @@
[1eE2]

View file

@ -0,0 +1 @@
[2.e+3]

View file

@ -0,0 +1 @@
[2.e-3]

View file

@ -0,0 +1 @@
[2.e3]

View file

@ -0,0 +1 @@
[9.e+]

View file

@ -0,0 +1 @@
[Inf]

View file

@ -0,0 +1 @@
[NaN]

View file

@ -0,0 +1 @@
[1+2]

View file

@ -0,0 +1 @@
[0x1]

View file

@ -0,0 +1 @@
[0x42]

View file

@ -0,0 +1 @@
[Infinity]

View file

@ -0,0 +1 @@
[0e+-1]

View file

@ -0,0 +1 @@
[-123.123foo]

View file

@ -0,0 +1 @@
[-Infinity]

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