Compare commits

..

68 Commits
1.7.5 ... 1.8.1

Author SHA1 Message Date
Christopher Dunn
a679dde58d 1.8.1 2017-06-25 22:01:22 -07:00
Christopher Dunn
c21b4bbfdb Merge pull request #625 from SoapGentoo/mesonise
Add initial Meson build file
2017-06-25 21:51:15 -07:00
David Seifert
d14d8c35c3 Update Travis configuration 2017-06-26 06:12:05 +02:00
David Seifert
ed258de63d Add initial Meson build file 2017-06-26 06:12:05 +02:00
Christopher Dunn
154652ee7a Merge pull request #623 from bernhardHartleb/master
Fix #567 in writing real values in different locales
2017-06-24 10:34:14 -07:00
Bernhard Hartleb
4a9d77bcf7 Fix issue #567 in writing real values in different locales
The output of snprintf might produce ',' separators for decimal places if
certain locales are set. This commit moves the converversion from ',' to '.'
to correct place. Otherwise an additional ".0" might be appended.
2017-06-22 22:46:16 +02:00
Christopher Dunn
56efb6ba83 Merge pull request #622 from sylvestre/master
Allocate the proper memory for formatString. Fix a warning with gcc 7.1
2017-06-12 19:44:58 -05:00
Sylvestre Ledru
7f9cc2705c Allocate the proper memory for formatString. Fix a warning with gcc 7.1
/root/firefox-gcc-last/toolkit/components/jsoncpp/src/lib_json/json_writer.cpp:139:16: note: using the range [-2147483648, 2147483647] for directive argument
/root/firefox-gcc-last/toolkit/components/jsoncpp/src/lib_json/json_writer.cpp:146:10: note: 'sprintf' output between 5 and 15 bytes into a destination of size 6
   sprintf(formatString, "%%.%dg", precision);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2017-06-09 22:41:48 +02:00
Christopher Dunn
d7347a2623 Merge pull request #609 from antonindrawan/QNX_Fix
Fix QNX build: QNX defines sprintf under the std namespace.
2017-05-01 21:52:55 -05:00
Anton Indrawan
2e319850d1 Fix QNX build: QNX defines sprintf under the std namespace. Use snprintf instead 2017-05-01 23:14:23 +02:00
Christopher Dunn
a3d35d7fb8 Merge pull request #607 from ssbr/master
Refactor authorship information for more technical accuracy.
2017-04-25 00:51:37 -05:00
Devin Jeanpierre
19fc55f408 Refactor authorship information for more technical accuracy.
Google advises its employees to add Google Inc. as an author, but that hasn't
been done yet and would be super inconvenient. So instead I've refactored the
file to refer to "The JsonCpp Authors", which are listed in the AUTHORS file.

The AUTHORS file itself is generated via:

    git log --pretty="%an <%ae>%n%cn <%ce>" | sort | uniq

Plus the addition of "Google Inc." as a copyright author. (Google owns the work
of anyone contributing from an @google.com address, for example.)

The list contains some probable duplicates where people have used more than one
email address. I didn't deduplicate because -- well, who's to say they're
duplicates, anyway? :)
2017-04-24 11:01:12 -07:00
Christopher Dunn
acf74290f1 Merge pull request #601 from paulobrizolara/master
Including instructions in how to use jsonCpp with conan
2017-04-09 21:47:09 -05:00
paulo
746ef154f1 Including instructions in how to use jsonCpp with conan
Also added the badge to the conan package.

Related to issue #564
2017-04-09 14:14:38 -03:00
Christopher Dunn
559b4416e6 Merge pull request #599 from pavel-pimenov/fix-v815
Fix V815:Decreased performance
2017-04-08 00:49:25 -05:00
pavel.pimenov
6ca374371e Fix V815:Decreased performance 2017-04-07 15:41:07 +03:00
Christopher Dunn
f7df408a6a Merge pull request #593 from AlB80/master
Optimize Value::isIntegral() method
2017-04-05 20:09:53 -05:00
Christopher Dunn
86ed860c4b Merge pull request #589 from ya1gaurav/patch-42
Fix warning issue with gcc flags.

closes #586
2017-04-05 19:50:21 -05:00
Alexander V. Brezgin
c442fd96e6 Optimize Value::isIntegral() method
Worst case called modf() twice
2017-03-29 06:37:37 +05:00
Gaurav
c68443f3a0 Fix Cmake build issue
FIx cmake build.
2017-03-10 10:33:03 +05:30
Gaurav
11c48d0047 Fix warning issue with gcc flags.
PR for - https://github.com/open-source-parsers/jsoncpp/issues/586
Separating the default options for compiler flags.
2017-03-10 10:22:33 +05:30
Christopher Dunn
264c3edca7 Merge pull request #573 from ya1gaurav/patch-39
Fix crash issue due to NULL value.
2017-03-09 16:06:37 -06:00
Christopher Dunn
a47fc398ef Merge pull request #571 from ibc/master
README: Give some love
2017-03-09 15:58:32 -06:00
David Seifert
2f178f390f Use full CMake paths in pkg-config template
Using full paths is more versatile. The current solution
breaks when specifying an absolute path for CMAKE_INSTALL_INCLUDEDIR
which is an otherwise supported option by CMake's GNUInstallDirs.
CMake does not support Autoconf-style ${prefix}-pseudo variables,
hence trying to emulate the behaviour gains us nothing and breaks
providing absolute paths to CMAKE_INSTALL_LIBDIR.
2017-03-09 07:13:45 -06:00
Gaurav
f251f15e6a Fix crash issue due to NULL value.
Null value in Value constructor will crash strlen(). Avoid crash with JSON_ASSERT_MESSAGE
2017-01-17 17:28:43 +05:30
Iñaki Baz Castillo
60bfcf1715 README: Give some love. 2017-01-12 11:24:29 +01:00
Christopher Dunn
81065748e3 Merge pull request #566 from open-source-parsers/update
std::min<unsigned>, for VS2015

fixes #565
2016-12-21 12:56:14 -06:00
Christopher Dunn
11836ae9aa std::min<unsigned>, for VS2015
fixes #565
2016-12-21 11:09:57 -06:00
Christopher Dunn
e25fb5384a Path for pkg-config
See #497, bottom comment.
2016-12-19 11:42:51 -06:00
Christopher Dunn
f700fe4559 Require cmake>=3.1
Plus some other build-related changes. I don't think there is anything
functionally different from 1.7.7, or even any binary incompatibilities, but
the cmake change is significant.
2016-12-14 13:39:05 -06:00
Christopher Dunn
d167a09b1c Merge pull request #562 from SoapGentoo/cmake-fixes
Replace current install variables with GNUInstallDirs
2016-12-14 13:30:53 -06:00
David Seifert
ba158fd22d Update Travis requirements for modern CMake 2016-12-14 17:53:10 +01:00
David Seifert
f3a4941590 Replace current install variables with GNUInstallDirs
* The GNUInstallDirs module is more idiomatic and supported by
  Kitware upstream, whereas the current directories are not
  standardised across CMake-using packages. Using CMake native
  mechanisms is better than reinventing the wheel, as it makes
  using the build system more uniform across the ecosystem
* Use CMAKE_CXX_STANDARD to force C++11
* Require CMake 3.1.0 at a minimum
* Fixed lower/UPPERcase format for function/macro calls
* Fixed indents by replacing tabs with 4 spaces
2016-12-14 17:53:10 +01:00
Christopher Dunn
0d25d9aebf Merge pull request #556 from Infotecs/nnkur-rec-fix
Removed a static variable used to contain the current recursion depth in json_reader.cpp
2016-12-09 10:47:17 -06:00
nnkur
5021e799dc Renamed JSONCPP_STACK_LIMIT to JSONCPP_DEPRECATED_STACK_LIMIT
Renamed JSONCPP_STACK_LIMIT to JSONCPP_DEPRECATED_STACK_LIMIT to stress that usage of this macros assumes old interface.
2016-12-07 15:47:08 +03:00
Christopher Dunn
762ad0fe9d Merge pull request #557 from sergiy80/master
Add pragma pack directive

resolves #458
2016-12-05 00:14:08 -06:00
Sergiy80
d6e666f573 Add pragma pack directive
Related to https://github.com/open-source-parsers/jsoncpp/issues/458
2016-12-03 22:29:14 +02:00
nnkur
2ecd2a59de Add files via upload
Removed a static variable used to contain the current recursion depth of Reader::readValue().  The number of elements in an internal container Reader::nodes_  is used instead.  It is correct because any recursive call of Reader::readValue() is executed with adjacent nodes_.push()  and nodes_.pop() calls.  
Added the option to change the allowed recursion depth at compile time by defining a macro JSONCPP_STACK_LIMIT as the required integer value.
2016-11-30 18:30:12 +03:00
Christopher Dunn
a691cb19de Merge pull request #553 from AlB80/master
Clarify code for value type return
2016-11-20 18:53:23 -06:00
Alexander V. Brezgin
ee7935986e Optimize value check 2016-11-20 03:55:08 +03:00
Alexander V. Brezgin
b4abc8241f Optimize value range check 2016-11-20 03:50:32 +03:00
Alexander V. Brezgin
12e9ef32f9 Remove repeated condition
isDouble() contains isIntegral()
2016-11-20 03:28:15 +03:00
Christopher Dunn
77632b2611 Merge pull request #549 from jia3ep/master
Added stack overflow test
2016-11-09 14:28:13 -06:00
Kirill V. Lyadvinsky
89aa87bd24 Use clang-3.5 since the Travis version has a conflict with gcc (check this issue https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=11;bug=744872) 2016-11-09 12:05:22 +03:00
Christopher Dunn
34fc0020c0 Merge pull request #552 from omki2005/noexcept
change throw() to noexcept to conform to c++11
2016-11-08 07:21:56 -06:00
Christopher Dunn
f880a9432d Merge pull request #551 from suttungdigital/detect_locale_support
Check for locale support in CMake
2016-11-08 07:19:51 -06:00
Magnus Bjerke Vik
5a82131033 Rename NO_LOCALE_SUPPORT to JSONCPP_NO_LOCALE_SUPPORT 2016-11-08 09:47:27 +01:00
Magnus Bjerke Vik
1839f2da34 Check for locale support in CMake 2016-11-08 09:47:27 +01:00
Omkar Wagh
91c1d23461 change throw() to noexcept to conform to c++11 2016-11-07 17:39:38 -05:00
Kirill V. Lyadvinsky
86f085b810 Make it a bit more multithreading friendly 2016-11-03 22:45:36 +03:00
Kirill V. Lyadvinsky
ac372d2b00 Added stack overflow test 2016-11-02 15:33:57 +03:00
Christopher Dunn
0e24e3c64f Merge pull request #547 from BrendanDrewDaqri/master
resolves #546: Ensure floating point values on input render as floats on output
2016-10-28 01:22:38 -05:00
Brendan Drew
89ab7eca7f Ensure that the fact that a float was provided on input is preserved when writing output; update tests to reflect this fact 2016-10-27 04:49:11 -07:00
Christopher Dunn
a1db52b030 Merge pull request #543 from chfast/patch-1
Rename variable empty to emptyString
2016-10-24 11:16:24 -05:00
Paweł Bylica
1572539bec Rename variable empty to emptyString
Rename variable empty to emptyString in Value constructor to avoid shadowing of Value::empty().

GCC 4.8 produces the warning about this:
lib_json/json_value.cpp: In constructor ‘Json::Value::Value(Json::ValueType)’:
lib_json/json_value.cpp:346:27: warning: declaration of ‘empty’ shadows a member of 'this' [-Wshadow]
2016-10-14 11:59:28 +02:00
Christopher Dunn
d8cd848ede 1.7.7 2016-10-02 11:32:21 -05:00
Christopher Dunn
92259f7147 Bump SOVERSION, separate from MAJOR.MINOR.MICRO 2016-10-02 11:29:12 -05:00
yiqiju
4a431bcdac Fix typo
resolves #538
2016-10-02 10:52:13 -05:00
Christopher Dunn
7d868636de Merge pull request #536 from vriera/master
resolves #537
closes #538
2016-09-27 20:12:01 -05:00
Vicente Olivert Riera
ab0f1e234a Include stdint.h necessary for int64_t and uint64_t
Otherwise failures like these one can happen during the configure phase
of other applications that use jsoncpp, like upmpdcli for instance:

checking jsoncpp/json/json.h usability... yes
checking jsoncpp/json/json.h presence... yes
checking for jsoncpp/json/json.h... yes
configure: error: libjsoncpp not found.

And this is the actual problem that you can see in config.log:

configure:5233: checking for jsoncpp/json/json.h
configure:5233: result: yes
configure:5259: /usr/bin/mipsel-linux-g++ -o conftest conftest.cpp
-lmicrohttpd -lmpdclient -lpthread  -ljsoncpp >&5
In file included from /usr/include/jsoncpp/json/autolink.h:9:0,
                 from /usr/include/jsoncpp/json/json.h:9,
                 from conftest.cpp:26:
/usr/include/jsoncpp/json/config.h:155:9: error: 'int64_t' does not name
a type
 typedef int64_t Int64;
         ^
/usr/include/jsoncpp/json/config.h:156:9: error: 'uint64_t' does not
name a type
 typedef uint64_t UInt64;
         ^

Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
2016-09-26 11:24:32 +01:00
Christopher Dunn
45a560a8c0 1.7.6 <- 1.7.5 2016-09-25 19:05:56 -05:00
Christopher Dunn
4893a8f667 Merge pull request #535 from kavika13/master
Add RPATH to dynamic library build on OSX

fixes #534 

But we will revert if there are any complaints.
2016-09-25 18:58:14 -05:00
Gergely Nagy
f6d785fda8 Fix poss SEGV
for non-null terminated input.
2016-09-25 18:45:04 -05:00
Merlyn Morgan-Graham
8d54e333ff Add RPATH to dynamic library build on OSX 2016-09-22 22:06:25 -07:00
Christopher Dunn
b063cf4ada Merge pull request #529 from chrox802/chrox802-patch-1
fix a bug about Json::Path
2016-09-07 21:57:56 -05:00
Christopher Dunn
c4ab6d733f Merge pull request #528 from DrMetallius/master
Used macros to disable localeconv() calls
2016-09-07 21:52:18 -05:00
chason
2f97c0147b fix a bug about Json::Path 2016-09-07 19:56:19 +08:00
Alexander Gazarov
52cfe5ae88 Replaced the template-based solution for avoiding calls to localeconv() with a macro-based one (fixes #527) 2016-09-06 14:41:13 +03:00
40 changed files with 614 additions and 257 deletions

4
.gitignore vendored
View File

@@ -30,8 +30,7 @@
# CMake-generated files: # CMake-generated files:
CMakeFiles/ CMakeFiles/
CTestTestFile.cmake *.cmake
cmake_install.cmake
pkg-config/jsoncpp.pc pkg-config/jsoncpp.pc
jsoncpp_lib_static.dir/ jsoncpp_lib_static.dir/
@@ -45,6 +44,7 @@ jsoncpp_lib_static.dir/
/src/lib_json/Makefile /src/lib_json/Makefile
/src/test_lib_json/Makefile /src/test_lib_json/Makefile
/src/test_lib_json/jsoncpp_test /src/test_lib_json/jsoncpp_test
*.a
# eclipse project files # eclipse project files
.project .project

View File

@@ -7,14 +7,24 @@
# to allow C++11, though we are not yet building with -std=c++11 # to allow C++11, though we are not yet building with -std=c++11
install: install:
- if [[ $TRAVIS_OS_NAME == osx ]]; then
brew update;
brew install python3 ninja;
python3 -m venv venv;
source venv/bin/activate;
elif [[ $TRAVIS_OS_NAME == linux ]]; then
wget https://github.com/ninja-build/ninja/releases/download/v1.7.2/ninja-linux.zip;
unzip -q ninja-linux.zip -d build;
fi
- pip3 install meson
# /usr/bin/gcc is 4.6 always, but gcc-X.Y is available. # /usr/bin/gcc is 4.6 always, but gcc-X.Y is available.
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi - if [[ $CXX = g++ ]]; then export CXX="g++-4.9" CC="gcc-4.9"; fi
# /usr/bin/clang is our version already, and clang-X.Y does not exist. # /usr/bin/clang has a conflict with gcc, so use clang-X.Y.
#- if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi - if [[ $CXX = clang++ ]]; then export CXX="clang++-3.5" CC="clang-3.5"; fi
- echo ${PATH} - echo ${PATH}
- ls /usr/local - ls /usr/local
- ls /usr/local/bin - ls /usr/local/bin
- export PATH=/usr/local/bin:/usr/bin:${PATH} - export PATH="${PWD}"/build:/usr/local/bin:/usr/bin:${PATH}
- echo ${CXX} - echo ${CXX}
- ${CXX} --version - ${CXX} --version
- which valgrind - which valgrind
@@ -22,10 +32,11 @@ addons:
apt: apt:
sources: sources:
- ubuntu-toolchain-r-test - ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.5
packages: packages:
- gcc-4.9 - gcc-4.9
- g++-4.9 - g++-4.9
- clang - clang-3.5
- valgrind - valgrind
os: os:
- linux - linux
@@ -36,8 +47,9 @@ compiler:
script: ./travis.sh script: ./travis.sh
env: env:
matrix: matrix:
- SHARED_LIB=ON STATIC_LIB=ON CMAKE_PKG=ON BUILD_TYPE=release VERBOSE_MAKE=false - LIB_TYPE=static BUILD_TYPE=release
- SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE_MAKE=true VERBOSE - LIB_TYPE=shared BUILD_TYPE=debug
notifications: notifications:
email: false email: false
dist: trusty
sudo: false sudo: false

110
AUTHORS
View File

@@ -1 +1,111 @@
Baptiste Lepilleur <blep@users.sourceforge.net> Baptiste Lepilleur <blep@users.sourceforge.net>
Aaron Jacobs <aaronjjacobs@gmail.com>
Aaron Jacobs <jacobsa@google.com>
Adam Boseley <ABoseley@agjunction.com>
Adam Boseley <adam.boseley@gmail.com>
Aleksandr Derbenev <13alexac@gmail.com>
Alexander Gazarov <DrMetallius@users.noreply.github.com>
Alexander V. Brezgin <abrezgin@appliedtech.ru>
Alexandr Brezgin <albrezgin@mail.ru>
Alexey Kruchinin <alexey@mopals.com>
Anton Indrawan <anton.indrawan@gmail.com>
Baptiste Jonglez <git@bitsofnetworks.org>
Baptiste Lepilleur <baptiste.lepilleur@gmail.com>
Baruch Siach <baruch@tkos.co.il>
Ben Boeckel <mathstuf@gmail.com>
Benjamin Knecht <bknecht@logitech.com>
Bernd Kuhls <bernd.kuhls@t-online.de>
Billy Donahue <billydonahue@google.com>
Braden McDorman <bmcdorman@gmail.com>
Brandon Myers <bmyers1788@gmail.com>
Brendan Drew <brendan.drew@daqri.com>
chason <cxchao802@gmail.com>
Chris Gilling <cgilling@iparadigms.com>
Christopher Dawes <christopher.dawes.1981@googlemail.com>
Christopher Dunn <cdunn2001@gmail.com>
Chuck Atkins <chuck.atkins@kitware.com>
Cody P Schafer <dev@codyps.com>
Connor Manning <connor@hobu.co>
Cory Quammen <cory.quammen@kitware.com>
Cristóvão B da Cruz e Silva <CrisXed@gmail.com>
Daniel Krügler <daniel.kruegler@gmail.com>
Dani-Hub <daniel.kruegler@googlemail.com>
Dan Liu <gzliudan>
datadiode <datadiode@users.noreply.github.com>
datadiode <jochen.neubeck@vodafone.de>
David Seifert <soap@gentoo.org>
David West <david-west@idexx.com>
dawesc <chris.dawes@eftlab.co.uk>
Dmitry Marakasov <amdmi3@amdmi3.ru>
dominicpezzuto <dom@dompezzuto.com>
Don Milham <dmilham@gmail.com>
drgler <daniel.kruegler@gmail.com>
ds283 <D.Seery@sussex.ac.uk>
Egor Tensin <Egor.Tensin@gmail.com>
eightnoteight <mr.eightnoteight@gmail.com>
Evince <baneyue@gmail.com>
filipjs <filipjs@users.noreply.github.com>
findblar <ft@finbarr.ca>
Florian Meier <florian.meier@koalo.de>
Gaëtan Lehmann <gaetan.lehmann@gmail.com>
Gaurav <g.gupta@samsung.com>
Gergely Nagy <ngg@ngg.hu>
Gida Pataki <gida.pataki@prezi.com>
I3ck <buckmartin@buckmartin.de>
Iñaki Baz Castillo <ibc@aliax.net>
Jacco <jacco@geul.net>
Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
Jonas Platte <mail@jonasplatte.de>
Jörg Krause <joerg.krause@embedded.rocks>
Keith Lea <keith@whamcitylights.com>
Kevin Grant <kbradleygrant@gmail.com>
Kirill V. Lyadvinsky <jia3ep@gmail.com>
Kirill V. Lyadvinsky <mail@codeatcpp.com>
Kobi Gurkan <kobigurk@gmail.com>
Magnus Bjerke Vik <mbvett@gmail.com>
Malay Shah <malays@users.sourceforge.net>
Mara Kim <hacker.root@gmail.com>
Marek Kotewicz <marek.kotewicz@gmail.com>
Mark Lakata <mark@lakata.org>
Mark Zeren <mzeren@vmware.com>
Martin Buck <buckmartin@buckmartin.de>
Martyn Gigg <martyn.gigg@gmail.com>
Mattes D <github@xoft.cz>
Matthias Loy <matthias.loy@hbm.com>
Merlyn Morgan-Graham <kavika@gmail.com>
Michael Shields <mshields@google.com>
Michał Górny <mgorny@gentoo.org>
Mike Naberezny <mike@naberezny.com>
mloy <matthias.loy@googlemail.com>
Motti <lanzkron@gmail.com>
nnkur <nnkur@mail.ru>
Omkar Wagh <owagh@owaghlinux.ny.tower-research.com>
paulo <paulobrizolara@users.noreply.github.com>
pavel.pimenov <pavel.pimenov@gmail.com>
Paweł Bylica <chfast@gmail.com>
Péricles Lopes Machado <pericles.raskolnikoff@gmail.com>
Peter Spiess-Knafl <psk@autistici.org>
pffang <pffang@vip.qq.com>
Rémi Verschelde <remi@verschelde.fr>
renu555 <renu.tyagi@samsung.com>
Robert Dailey <rcdailey@gmail.com>
Sam Clegg <sbc@chromium.org>
selaselah <selah@outlook.com>
Sergiy80 <sil2004@gmail.com>
sergzub <sergzub@gmail.com>
Stefan Schweter <stefan@schweter.it>
Steffen Kieß <Steffen.Kiess@ipvs.uni-stuttgart.de>
Steven Hahn <hahnse@ornl.gov>
Stuart Eichert <stuart@fivemicro.com>
SuperManitu <supermanitu@gmail.com>
Techwolf <dring@g33kworld.net>
Tengiz Sharafiev <btolfa+github@gmail.com>
Tomasz Maciejewski <tmaciejewsk@gmail.com>
Vicente Olivert Riera <Vincent.Riera@imgtec.com>
xiaoyur347 <xiaoyur347@gmail.com>
ycqiu <429148848@qq.com>
yiqiju <fred_ju@selinc.com>
Yu Xiaolei <dreifachstein@gmail.com>
Google Inc.

View File

@@ -1,6 +1,6 @@
# vim: et ts=4 sts=4 sw=4 tw=0 # vim: et ts=4 sts=4 sw=4 tw=0
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.5) CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
PROJECT(jsoncpp) PROJECT(jsoncpp)
ENABLE_TESTING() ENABLE_TESTING()
@@ -22,20 +22,15 @@ IF(NOT WIN32)
ENDIF() ENDIF()
ENDIF() ENDIF()
SET(DEBUG_LIBNAME_SUFFIX "" CACHE STRING "Optional suffix to append to the library name for a debug build") # Enable runtime search path support for dynamic libraries on OSX
SET(LIB_SUFFIX "" CACHE STRING "Optional arch-dependent suffix for the library installation directory") IF(APPLE)
SET(CMAKE_MACOSX_RPATH 1)
ENDIF()
SET(RUNTIME_INSTALL_DIR bin # Adhere to GNU filesystem layout conventions
CACHE PATH "Install dir for executables and dlls") INCLUDE(GNUInstallDirs)
SET(ARCHIVE_INSTALL_DIR lib${LIB_SUFFIX}
CACHE PATH "Install dir for static libraries") SET(DEBUG_LIBNAME_SUFFIX "" CACHE STRING "Optional suffix to append to the library name for a debug build")
SET(LIBRARY_INSTALL_DIR lib${LIB_SUFFIX}
CACHE PATH "Install dir for shared libraries")
SET(INCLUDE_INSTALL_DIR include
CACHE PATH "Install dir for headers")
SET(PACKAGE_INSTALL_DIR lib${LIB_SUFFIX}/cmake
CACHE PATH "Install dir for cmake package config files")
MARK_AS_ADVANCED( RUNTIME_INSTALL_DIR ARCHIVE_INSTALL_DIR INCLUDE_INSTALL_DIR PACKAGE_INSTALL_DIR )
# Set variable named ${VAR_NAME} to value ${VALUE} # Set variable named ${VAR_NAME} to value ${VALUE}
FUNCTION(set_using_dynamic_name VAR_NAME VALUE) FUNCTION(set_using_dynamic_name VAR_NAME VALUE)
@@ -64,11 +59,12 @@ ENDMACRO()
#SET( JSONCPP_VERSION_MAJOR X ) #SET( JSONCPP_VERSION_MAJOR X )
#SET( JSONCPP_VERSION_MINOR Y ) #SET( JSONCPP_VERSION_MINOR Y )
#SET( JSONCPP_VERSION_PATCH Z ) #SET( JSONCPP_VERSION_PATCH Z )
SET( JSONCPP_VERSION 1.7.5 ) SET( JSONCPP_VERSION 1.8.1 )
jsoncpp_parse_version( ${JSONCPP_VERSION} JSONCPP_VERSION ) jsoncpp_parse_version( ${JSONCPP_VERSION} JSONCPP_VERSION )
#IF(NOT JSONCPP_VERSION_FOUND) #IF(NOT JSONCPP_VERSION_FOUND)
# MESSAGE(FATAL_ERROR "Failed to parse version string properly. Expect X.Y.Z") # MESSAGE(FATAL_ERROR "Failed to parse version string properly. Expect X.Y.Z")
#ENDIF(NOT JSONCPP_VERSION_FOUND) #ENDIF(NOT JSONCPP_VERSION_FOUND)
SET( JSONCPP_SOVERSION 11 )
SET( JSONCPP_USE_SECURE_MEMORY "0" CACHE STRING "-D...=1 to use memory-wiping allocator for STL" ) SET( JSONCPP_USE_SECURE_MEMORY "0" CACHE STRING "-D...=1 to use memory-wiping allocator for STL" )
MESSAGE(STATUS "JsonCpp Version: ${JSONCPP_VERSION_MAJOR}.${JSONCPP_VERSION_MINOR}.${JSONCPP_VERSION_PATCH}") MESSAGE(STATUS "JsonCpp Version: ${JSONCPP_VERSION_MAJOR}.${JSONCPP_VERSION_MINOR}.${JSONCPP_VERSION_PATCH}")
@@ -80,70 +76,79 @@ CONFIGURE_FILE( "${PROJECT_SOURCE_DIR}/version.in"
"${PROJECT_SOURCE_DIR}/version" "${PROJECT_SOURCE_DIR}/version"
NEWLINE_STYLE UNIX ) NEWLINE_STYLE UNIX )
macro(UseCompilationWarningAsError) MACRO(UseCompilationWarningAsError)
if ( MSVC ) IF(MSVC)
# Only enabled in debug because some old versions of VS STL generate # Only enabled in debug because some old versions of VS STL generate
# warnings when compiled in release configuration. # warnings when compiled in release configuration.
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /WX ") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /WX ")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
if (JSONCPP_WITH_STRICT_ISO) IF(JSONCPP_WITH_STRICT_ISO)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors")
endif () ENDIF()
endif() ENDIF()
endmacro() ENDMACRO()
# Include our configuration header # Include our configuration header
INCLUDE_DIRECTORIES( ${jsoncpp_SOURCE_DIR}/include ) INCLUDE_DIRECTORIES( ${jsoncpp_SOURCE_DIR}/include )
if ( MSVC ) IF(MSVC)
# Only enabled in debug because some old versions of VS STL generate # Only enabled in debug because some old versions of VS STL generate
# unreachable code warning when compiled in release configuration. # unreachable code warning when compiled in release configuration.
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4 ") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4 ")
endif() ENDIF()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") # Require C++11 support, prefer ISO C++ over GNU variants,
# using regular Clang or AppleClang # as relying solely on ISO C++ is more portable.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wconversion -Wshadow -Werror=conversion -Werror=sign-compare") SET(CMAKE_CXX_STANDARD 11)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") SET(CMAKE_CXX_STANDARD_REQUIRED ON)
# using GCC SET(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wconversion -Wshadow -Wextra")
# not yet ready for -Wsign-conversion
if (JSONCPP_WITH_STRICT_ISO AND NOT JSONCPP_WITH_WARNING_AS_ERROR) IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=conversion -pedantic") # using regular Clang or AppleClang
endif () SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wconversion -Wshadow -Werror=conversion -Werror=sign-compare")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# using Intel compiler # using GCC
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wconversion -Wshadow -Wextra -Werror=conversion") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wconversion -Wshadow -Wextra")
# not yet ready for -Wsign-conversion
if (JSONCPP_WITH_STRICT_ISO AND NOT JSONCPP_WITH_WARNING_AS_ERROR) IF(JSONCPP_WITH_STRICT_ISO)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
endif () ENDIF()
endif() IF(JSONCPP_WITH_WARNING_AS_ERROR)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=conversion")
ENDIF()
ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
# using Intel compiler
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wconversion -Wshadow -Wextra -Werror=conversion")
find_program(CCACHE_FOUND ccache) IF(JSONCPP_WITH_STRICT_ISO AND NOT JSONCPP_WITH_WARNING_AS_ERROR)
if(CCACHE_FOUND) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) ENDIF()
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) ENDIF()
endif(CCACHE_FOUND)
FIND_PROGRAM(CCACHE_FOUND ccache)
IF(CCACHE_FOUND)
SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
ENDIF(CCACHE_FOUND)
IF(JSONCPP_WITH_WARNING_AS_ERROR) IF(JSONCPP_WITH_WARNING_AS_ERROR)
UseCompilationWarningAsError() UseCompilationWarningAsError()
ENDIF() ENDIF()
IF(JSONCPP_WITH_PKGCONFIG_SUPPORT) IF(JSONCPP_WITH_PKGCONFIG_SUPPORT)
CONFIGURE_FILE( CONFIGURE_FILE(
"pkg-config/jsoncpp.pc.in" "pkg-config/jsoncpp.pc.in"
"pkg-config/jsoncpp.pc" "pkg-config/jsoncpp.pc"
@ONLY) @ONLY)
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/pkg-config/jsoncpp.pc" INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/pkg-config/jsoncpp.pc"
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig") DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
ENDIF() ENDIF()
IF(JSONCPP_WITH_CMAKE_PACKAGE) IF(JSONCPP_WITH_CMAKE_PACKAGE)
INSTALL(EXPORT jsoncpp INSTALL(EXPORT jsoncpp
DESTINATION ${PACKAGE_INSTALL_DIR}/jsoncpp DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp
FILE jsoncppConfig.cmake) FILE jsoncppConfig.cmake)
ENDIF() ENDIF()

View File

@@ -2,12 +2,12 @@ The JsonCpp library's source code, including accompanying documentation,
tests and demonstration applications, are licensed under the following tests and demonstration applications, are licensed under the following
conditions... conditions...
The author (Baptiste Lepilleur) explicitly disclaims copyright in all The JsonCpp Authors explicitly disclaim copyright in all
jurisdictions which recognize such a disclaimer. In such jurisdictions, jurisdictions which recognize such a disclaimer. In such jurisdictions,
this software is released into the Public Domain. this software is released into the Public Domain.
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is 2010), this software is Copyright (c) 2007-2010 by The JsonCpp Authors, and is
released under the terms of the MIT License (see below). released under the terms of the MIT License (see below).
In jurisdictions which recognize Public Domain property, the user of this In jurisdictions which recognize Public Domain property, the user of this
@@ -23,7 +23,7 @@ described in clear, concise terms at:
The full text of the MIT License follows: The full text of the MIT License follows:
======================================================================== ========================================================================
Copyright (c) 2007-2010 Baptiste Lepilleur Copyright (c) 2007-2010 The JsonCpp Authors
Permission is hereby granted, free of charge, to any person Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation obtaining a copy of this software and associated documentation

132
README.md
View File

@@ -1,5 +1,6 @@
Introduction # JsonCpp
------------
[![badge](https://img.shields.io/badge/conan.io-jsoncpp%2F1.8.0-green.svg?logo=data:image/png;base64%2CiVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAMAAAAolt3jAAAA1VBMVEUAAABhlctjlstkl8tlmMtlmMxlmcxmmcxnmsxpnMxpnM1qnc1sn85voM91oM11oc1xotB2oc56pNF6pNJ2ptJ8ptJ8ptN9ptN8p9N5qNJ9p9N9p9R8qtOBqdSAqtOAqtR%2BrNSCrNJ/rdWDrNWCsNWCsNaJs9eLs9iRvNuVvdyVv9yXwd2Zwt6axN6dxt%2Bfx%2BChyeGiyuGjyuCjyuGly%2BGlzOKmzOGozuKoz%2BKqz%2BOq0OOv1OWw1OWw1eWx1eWy1uay1%2Baz1%2Baz1%2Bez2Oe02Oe12ee22ujUGwH3AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfgBQkREyOxFIh/AAAAiklEQVQI12NgAAMbOwY4sLZ2NtQ1coVKWNvoc/Eq8XDr2wB5Ig62ekza9vaOqpK2TpoMzOxaFtwqZua2Bm4makIM7OzMAjoaCqYuxooSUqJALjs7o4yVpbowvzSUy87KqSwmxQfnsrPISyFzWeWAXCkpMaBVIC4bmCsOdgiUKwh3JojLgAQ4ZCE0AMm2D29tZwe6AAAAAElFTkSuQmCC)](http://www.conan.io/source/jsoncpp/1.8.0/theirix/ci)
[JSON][json-org] is a lightweight data-interchange format. It can represent [JSON][json-org] is a lightweight data-interchange format. It can represent
numbers, strings, ordered sequences of values, and collections of name/value numbers, strings, ordered sequences of values, and collections of name/value
@@ -7,20 +8,29 @@ pairs.
[json-org]: http://json.org/ [json-org]: http://json.org/
[JsonCpp][] is a C++ library that allows manipulating JSON values, including JsonCpp is a C++ library that allows manipulating JSON values, including
serialization and deserialization to and from strings. It can also preserve serialization and deserialization to and from strings. It can also preserve
existing comment in unserialization/serialization steps, making it a convenient existing comment in unserialization/serialization steps, making it a convenient
format to store user input files. format to store user input files.
[JsonCpp]: http://open-source-parsers.github.io/jsoncpp-docs/doxygen/index.html
## Documentation
[JsonCpp documentation][JsonCpp-documentation] is generated using [Doxygen][].
[JsonCpp-documentation]: http://open-source-parsers.github.io/jsoncpp-docs/doxygen/index.html
[Doxygen]: http://www.doxygen.org
## A note on backward-compatibility ## A note on backward-compatibility
* `1.y.z` is built with C++11. * `1.y.z` is built with C++11.
* `0.y.z` can be used with older compilers. * `0.y.z` can be used with older compilers.
* Major versions maintain binary-compatibility. * Major versions maintain binary-compatibility.
# Using JsonCpp in your project
----------------------------- ## Using JsonCpp in your project
The recommended approach to integrating JsonCpp in your project is to include The recommended approach to integrating JsonCpp in your project is to include
the [amalgamated source](#generating-amalgamated-source-and-header) (a single the [amalgamated source](#generating-amalgamated-source-and-header) (a single
`.cpp` file and two `.h` files) in your project, and compile and build as you `.cpp` file and two `.h` files) in your project, and compile and build as you
@@ -28,16 +38,15 @@ would any other source file. This ensures consistency of compilation flags and
ABI compatibility, issues which arise when building shared or static ABI compatibility, issues which arise when building shared or static
libraries. See the next section for instructions. libraries. See the next section for instructions.
The `include/` should be added to your compiler include path. Jsoncpp headers The `include/` should be added to your compiler include path. JsonCpp headers
should be included as follow: should be included as follow:
#include <json/json.h> #include <json/json.h>
If JsonCpp was built as a dynamic library on Windows, then your project needs to If JsonCpp was built as a dynamic library on Windows, then your project needs to define the macro `JSON_DLL`.
define the macro `JSON_DLL`.
### Generating amalgamated source and header
Generating amalgamated source and header
----------------------------------------
JsonCpp is provided with a script to generate a single header and a single JsonCpp is provided with a script to generate a single header and a single
source file to ease inclusion into an existing project. The amalgamated source source file to ease inclusion into an existing project. The amalgamated source
can be generated at any time by running the following command from the can be generated at any time by running the following command from the
@@ -48,6 +57,7 @@ top-directory (this requires Python 2.6):
It is possible to specify header name. See the `-h` option for detail. It is possible to specify header name. See the `-h` option for detail.
By default, the following files are generated: By default, the following files are generated:
* `dist/jsoncpp.cpp`: source file that needs to be added to your project. * `dist/jsoncpp.cpp`: source file that needs to be added to your project.
* `dist/json/json.h`: corresponding header file for use in your project. It is * `dist/json/json.h`: corresponding header file for use in your project. It is
equivalent to including `json/json.h` in non-amalgamated source. This header equivalent to including `json/json.h` in non-amalgamated source. This header
@@ -56,15 +66,51 @@ By default, the following files are generated:
JsonCpp types. JsonCpp types.
The amalgamated sources are generated by concatenating JsonCpp source in the The amalgamated sources are generated by concatenating JsonCpp source in the
correct order and defining the macro `JSON_IS_AMALGAMATION` to prevent inclusion correct order and defining the macro `JSON_IS_AMALGAMATION` to prevent inclusion of other headers.
of other headers.
# Contributing to JsonCpp
Building and testing with CMake ## Contributing to JsonCpp
-------------------------------
[CMake][] is a C++ Makefiles/Solution generator. It is usually available on most ### Building and testing with Conan
Linux system as package. On Ubuntu:
[Conan](https://www.conan.io/#/) is an open source package manager intended for C/C++ projects.
It is cross platform and build system agnostic.
Conan requires Python for running, and can be installed using pip:
pip install conan
Detailed instructions can be found on [conan docs](http://docs.conan.io/en/latest/).
For build jsoncpp with conan, you need to create a [conanfile.txt](http://docs.conan.io/en/latest/reference/conanfile_txt.html) or a [conanfile.py](http://docs.conan.io/en/latest/reference/conanfile.html). The first is simpler, but the second is more flexible.
This is a sample conanfile.txt:
```
[requires]
jsoncpp/1.8.0@theirix/ci
[generators]
cmake
```
**Note**: cmake is not required, you can use other [integrations](http://docs.conan.io/en/latest/integrations.html). Or you can set the appropriate environment variables, using [virtualenv generators](http://docs.conan.io/en/latest/mastering/virtualenv.html).
Then run the following command from the conanfile directory:
conan install --build missing
This will try to download the appropriate package for your settings (OS, compiler, architecture) from the [recipe packages](https://www.conan.io/source/jsoncpp/1.8.0/theirix/ci). If it is not found, the package will be built.
**Note**: you do not need to install cmake to build jsoncpp using conan, because the recipe will download it automatically.
If you need, you can customize the jsoncpp recipe. Just clone/fork [it from github](https://github.com/theirix/conan-jsoncpp/).
See [integrations instructions](http://docs.conan.io/en/latest/integrations.html) for how to use your build system with conan.
### Building and testing with CMake
[CMake][] is a C++ Makefiles/Solution generator. It is usually available on most Linux system as package. On Ubuntu:
sudo apt-get install cmake sudo apt-get install cmake
@@ -75,9 +121,9 @@ missing, the build will skip running those tests.
When running CMake, a few parameters are required: When running CMake, a few parameters are required:
* a build directory where the makefiles/solution are generated. It is also used * A build directory where the makefiles/solution are generated. It is also used
to store objects, libraries and executables files. to store objects, libraries and executables files.
* the generator to use: makefiles or Visual Studio solution? What version or * The generator to use: makefiles or Visual Studio solution? What version or
Visual Studio, 32 or 64 bits solution? Visual Studio, 32 or 64 bits solution?
Steps for generating solution/makefiles using `cmake-gui`: Steps for generating solution/makefiles using `cmake-gui`:
@@ -97,16 +143,20 @@ Alternatively, from the command-line on Unix in the source directory:
cmake -DCMAKE_BUILD_TYPE=debug -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF -DARCHIVE_INSTALL_DIR=. -G "Unix Makefiles" ../.. cmake -DCMAKE_BUILD_TYPE=debug -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF -DARCHIVE_INSTALL_DIR=. -G "Unix Makefiles" ../..
make make
For a good pkg-config file, add:
-DCMAKE_INSTALL_INCLUDEDIR=include/jsoncpp
Running `cmake -h` will display the list of available generators (passed using Running `cmake -h` will display the list of available generators (passed using
the `-G` option). the `-G` option).
By default CMake hides compilation commands. This can be modified by specifying By default CMake hides compilation commands. This can be modified by specifying
`-DCMAKE_VERBOSE_MAKEFILE=true` when generating makefiles. `-DCMAKE_VERBOSE_MAKEFILE=true` when generating makefiles.
Building and testing with SCons ### Building and testing with SCons
-------------------------------
**Note:** The SCons-based build system is deprecated. Please use CMake; see the **Note:** The SCons-based build system is deprecated. Please use CMake (see the
section above. section above).
JsonCpp can use [Scons][] as a build system. Note that SCons requires Python to JsonCpp can use [Scons][] as a build system. Note that SCons requires Python to
be installed. be installed.
@@ -133,7 +183,8 @@ If you are building with Microsoft Visual Studio 2008, you need to set up the
environment by running `vcvars32.bat` (e.g. MSVC 2008 command prompt) before environment by running `vcvars32.bat` (e.g. MSVC 2008 command prompt) before
running SCons. running SCons.
## Running the tests manually ### Running the tests manually
You need to run tests manually only if you are troubleshooting an issue. You need to run tests manually only if you are troubleshooting an issue.
In the instructions below, replace `path/to/jsontest` with the path of the In the instructions below, replace `path/to/jsontest` with the path of the
@@ -156,21 +207,22 @@ In the instructions below, replace `path/to/jsontest` with the path of the
# You can run the tests using valgrind: # You can run the tests using valgrind:
python rununittests.py --valgrind path/to/test_lib_json python rununittests.py --valgrind path/to/test_lib_json
## Running the tests using scons ### Running the tests using SCons
Note that tests can be run using SCons using the `check` target: Note that tests can be run using SCons using the `check` target:
scons platform=$PLATFORM check scons platform=$PLATFORM check
Building the documentation ### Building the documentation
--------------------------
Run the Python script `doxybuild.py` from the top directory: Run the Python script `doxybuild.py` from the top directory:
python doxybuild.py --doxygen=$(which doxygen) --open --with-dot python doxybuild.py --doxygen=$(which doxygen) --open --with-dot
See `doxybuild.py --help` for options. See `doxybuild.py --help` for options.
Adding a reader/writer test ### Adding a reader/writer test
---------------------------
To add a test, you need to create two files in test/data: To add a test, you need to create two files in test/data:
* a `TESTNAME.json` file, that contains the input document in JSON format. * a `TESTNAME.json` file, that contains the input document in JSON format.
@@ -179,21 +231,19 @@ To add a test, you need to create two files in test/data:
The `TESTNAME.expected` file format is as follows: The `TESTNAME.expected` file format is as follows:
* each line represents a JSON element of the element tree represented by the * Each line represents a JSON element of the element tree represented by the
input document. input document.
* each line has two parts: the path to access the element separated from the * Each line has two parts: the path to access the element separated from the
element value by `=`. Array and object values are always empty (i.e. element value by `=`. Array and object values are always empty (i.e.
represented by either `[]` or `{}`). represented by either `[]` or `{}`).
* element path: `.` represents the root element, and is used to separate object * Element path `.` represents the root element, and is used to separate object
members. `[N]` is used to specify the value of an array element at index `N`. members. `[N]` is used to specify the value of an array element at index `N`.
See the examples `test_complex_01.json` and `test_complex_01.expected` to better See the examples `test_complex_01.json` and `test_complex_01.expected` to better understand element paths.
understand element paths.
Understanding reader/writer test output ### Understanding reader/writer test output
---------------------------------------
When a test is run, output files are generated beside the input test files. When a test is run, output files are generated beside the input test files. Below is a short description of the content of each file:
Below is a short description of the content of each file:
* `test_complex_01.json`: input JSON document. * `test_complex_01.json`: input JSON document.
* `test_complex_01.expected`: flattened JSON element tree used to check if * `test_complex_01.expected`: flattened JSON element tree used to check if
@@ -208,7 +258,7 @@ Below is a short description of the content of each file:
* `test_complex_01.process-output`: `jsontest` output, typically useful for * `test_complex_01.process-output`: `jsontest` output, typically useful for
understanding parsing errors. understanding parsing errors.
License ## License
-------
See the `LICENSE` file for details. In summary, JsonCpp is licensed under the See the `LICENSE` file for details. In summary, JsonCpp is licensed under the
MIT license, or public domain if desired and recognized in your jurisdiction. MIT license, or public domain if desired and recognized in your jurisdiction.

View File

@@ -1,4 +1,4 @@
# Copyright 2010 Baptiste Lepilleur # Copyright 2010 The JsonCpp Authors
# Distributed under MIT license, or public domain if desired and # Distributed under MIT license, or public domain if desired and
# recognized in your jurisdiction. # recognized in your jurisdiction.
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE # See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
# encoding: utf-8 # encoding: utf-8
# Copyright 2009 Baptiste Lepilleur # Copyright 2009 The JsonCpp Authors
# Distributed under MIT license, or public domain if desired and # Distributed under MIT license, or public domain if desired and
# recognized in your jurisdiction. # recognized in your jurisdiction.
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE # See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE

View File

@@ -1,4 +1,4 @@
# Copyright 2010 Baptiste Lepilleur # Copyright 2010 The JsonCpp Authors
# Distributed under MIT license, or public domain if desired and # Distributed under MIT license, or public domain if desired and
# recognized in your jurisdiction. # recognized in your jurisdiction.
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE # See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE

View File

@@ -6,7 +6,7 @@ from __future__ import print_function
# and ends with the first blank line. # and ends with the first blank line.
LICENSE_BEGIN = "// Copyright " LICENSE_BEGIN = "// Copyright "
BRIEF_LICENSE = LICENSE_BEGIN + """2007-2010 Baptiste Lepilleur BRIEF_LICENSE = LICENSE_BEGIN + """2007-2010 The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and // Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction. // recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE

View File

@@ -1,4 +1,4 @@
# Copyright 2010 Baptiste Lepilleur # Copyright 2010 The JsonCpp Authors
# Distributed under MIT license, or public domain if desired and # Distributed under MIT license, or public domain if desired and
# recognized in your jurisdiction. # recognized in your jurisdiction.
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE # See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE

View File

@@ -1,2 +1,2 @@
FILE(GLOB INCLUDE_FILES "json/*.h") FILE(GLOB INCLUDE_FILES "json/*.h")
INSTALL(FILES ${INCLUDE_FILES} DESTINATION ${INCLUDE_INSTALL_DIR}/json) INSTALL(FILES ${INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/json)

View File

@@ -9,6 +9,8 @@
#include <cstring> #include <cstring>
#include <memory> #include <memory>
#pragma pack(push, 8)
namespace Json { namespace Json {
template<typename T> template<typename T>
class SecureAllocator { class SecureAllocator {
@@ -91,4 +93,6 @@ bool operator!=(const SecureAllocator<T>&, const SecureAllocator<U>&) {
} //namespace Json } //namespace Json
#pragma pack(pop)
#endif // CPPTL_JSON_ALLOCATOR_H_INCLUDED #endif // CPPTL_JSON_ALLOCATOR_H_INCLUDED

View File

@@ -6,7 +6,8 @@
#ifndef JSON_CONFIG_H_INCLUDED #ifndef JSON_CONFIG_H_INCLUDED
#define JSON_CONFIG_H_INCLUDED #define JSON_CONFIG_H_INCLUDED
#include <stddef.h> #include <stddef.h>
#include <string> //typdef String #include <string> //typedef String
#include <stdint.h> //typedef int64_t, uint64_t
/// If defined, indicates that json library is embedded in CppTL library. /// If defined, indicates that json library is embedded in CppTL library.
//# define JSON_IN_CPPTL 1 //# define JSON_IN_CPPTL 1
@@ -82,10 +83,16 @@
// managable and fixes a set of common hard-to-find bugs. // managable and fixes a set of common hard-to-find bugs.
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
# define JSONCPP_OVERRIDE override # define JSONCPP_OVERRIDE override
#elif defined(_MSC_VER) && _MSC_VER > 1600 # define JSONCPP_NOEXCEPT noexcept
#elif defined(_MSC_VER) && _MSC_VER > 1600 && _MSC_VER < 1900
# define JSONCPP_OVERRIDE override # define JSONCPP_OVERRIDE override
# define JSONCPP_NOEXCEPT throw()
#elif defined(_MSC_VER) && _MSC_VER >= 1900
# define JSONCPP_OVERRIDE override
# define JSONCPP_NOEXCEPT noexcept
#else #else
# define JSONCPP_OVERRIDE # define JSONCPP_OVERRIDE
# define JSONCPP_NOEXCEPT throw()
#endif #endif
#ifndef JSON_HAS_RVALUE_REFERENCES #ifndef JSON_HAS_RVALUE_REFERENCES

View File

@@ -10,6 +10,8 @@
#include "forwards.h" #include "forwards.h"
#endif // if !defined(JSON_IS_AMALGAMATION) #endif // if !defined(JSON_IS_AMALGAMATION)
#pragma pack(push, 8)
namespace Json { namespace Json {
/** \brief Configuration passed to reader and writer. /** \brief Configuration passed to reader and writer.
@@ -54,4 +56,6 @@ public:
} // namespace Json } // namespace Json
#pragma pack(pop)
#endif // CPPTL_JSON_FEATURES_H_INCLUDED #endif // CPPTL_JSON_FEATURES_H_INCLUDED

View File

@@ -23,6 +23,8 @@
#pragma warning(disable : 4251) #pragma warning(disable : 4251)
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#pragma pack(push, 8)
namespace Json { namespace Json {
/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a /** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a
@@ -397,6 +399,8 @@ JSON_API JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM&, Value&);
} // namespace Json } // namespace Json
#pragma pack(pop)
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#pragma warning(pop) #pragma warning(pop)
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)

View File

@@ -42,6 +42,8 @@
#pragma warning(disable : 4251) #pragma warning(disable : 4251)
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#pragma pack(push, 8)
/** \brief JSON (JavaScript Object Notation). /** \brief JSON (JavaScript Object Notation).
*/ */
namespace Json { namespace Json {
@@ -53,8 +55,8 @@ namespace Json {
class JSON_API Exception : public std::exception { class JSON_API Exception : public std::exception {
public: public:
Exception(JSONCPP_STRING const& msg); Exception(JSONCPP_STRING const& msg);
~Exception() throw() JSONCPP_OVERRIDE; ~Exception() JSONCPP_NOEXCEPT JSONCPP_OVERRIDE;
char const* what() const throw() JSONCPP_OVERRIDE; char const* what() const JSONCPP_NOEXCEPT JSONCPP_OVERRIDE;
protected: protected:
JSONCPP_STRING msg_; JSONCPP_STRING msg_;
}; };
@@ -859,6 +861,7 @@ template<>
inline void swap(Json::Value& a, Json::Value& b) { a.swap(b); } inline void swap(Json::Value& a, Json::Value& b) { a.swap(b); }
} }
#pragma pack(pop)
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#pragma warning(pop) #pragma warning(pop)

View File

@@ -3,10 +3,10 @@
#ifndef JSON_VERSION_H_INCLUDED #ifndef JSON_VERSION_H_INCLUDED
# define JSON_VERSION_H_INCLUDED # define JSON_VERSION_H_INCLUDED
# define JSONCPP_VERSION_STRING "1.7.5" # define JSONCPP_VERSION_STRING "1.8.1"
# define JSONCPP_VERSION_MAJOR 1 # define JSONCPP_VERSION_MAJOR 1
# define JSONCPP_VERSION_MINOR 7 # define JSONCPP_VERSION_MINOR 8
# define JSONCPP_VERSION_PATCH 5 # define JSONCPP_VERSION_PATCH 1
# define JSONCPP_VERSION_QUALIFIER # define JSONCPP_VERSION_QUALIFIER
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8)) # define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))

View File

@@ -20,6 +20,8 @@
#pragma warning(disable : 4251) #pragma warning(disable : 4251)
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#pragma pack(push, 8)
namespace Json { namespace Json {
class Value; class Value;
@@ -324,6 +326,8 @@ JSON_API JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM&, const Value& root);
} // namespace Json } // namespace Json
#pragma pack(pop)
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#pragma warning(pop) #pragma warning(pop)
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)

View File

@@ -1,4 +1,4 @@
# Copyright 2010 Baptiste Lepilleur # Copyright 2010 The JsonCpp Authors
# Distributed under MIT license, or public domain if desired and # Distributed under MIT license, or public domain if desired and
# recognized in your jurisdiction. # recognized in your jurisdiction.
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE # See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE

102
meson.build Normal file
View File

@@ -0,0 +1,102 @@
project(
'jsoncpp',
'cpp',
version : '1.8.1',
default_options : [
'buildtype=release',
'warning_level=1'],
license : 'Public Domain',
meson_version : '>= 0.41.1')
jsoncpp_ver_arr = meson.project_version().split('.')
jsoncpp_major_version = jsoncpp_ver_arr[0]
jsoncpp_minor_version = jsoncpp_ver_arr[1]
jsoncpp_patch_version = jsoncpp_ver_arr[2]
jsoncpp_cdata = configuration_data()
jsoncpp_cdata.set('JSONCPP_VERSION', meson.project_version())
jsoncpp_cdata.set('JSONCPP_VERSION_MAJOR', jsoncpp_major_version)
jsoncpp_cdata.set('JSONCPP_VERSION_MINOR', jsoncpp_minor_version)
jsoncpp_cdata.set('JSONCPP_VERSION_PATCH', jsoncpp_patch_version)
jsoncpp_gen_sources = configure_file(
input : 'src/lib_json/version.h.in',
output : 'version.h',
configuration : jsoncpp_cdata,
install : true,
install_dir : join_paths(get_option('prefix'), get_option('includedir'), 'json')
)
jsoncpp_headers = [
'include/json/allocator.h',
'include/json/assertions.h',
'include/json/autolink.h',
'include/json/config.h',
'include/json/features.h',
'include/json/forwards.h',
'include/json/json.h',
'include/json/reader.h',
'include/json/value.h',
'include/json/writer.h']
jsoncpp_include_directories = include_directories('include')
install_headers(
jsoncpp_headers,
subdir : 'json')
jsoncpp_lib = library(
'jsoncpp',
[ jsoncpp_gen_sources,
jsoncpp_headers,
'src/lib_json/json_tool.h',
'src/lib_json/json_reader.cpp',
'src/lib_json/json_value.cpp',
'src/lib_json/json_writer.cpp'],
soversion : 18,
install : true,
include_directories : jsoncpp_include_directories)
import('pkgconfig').generate(
libraries : jsoncpp_lib,
version : meson.project_version(),
name : 'jsoncpp',
filebase : 'jsoncpp',
description : 'A C++ library for interacting with JSON')
# for libraries bundling jsoncpp
declare_dependency(
include_directories : jsoncpp_include_directories,
link_with : jsoncpp_lib,
version : meson.project_version(),
sources : jsoncpp_gen_sources)
# tests
python = import('python3').find_python()
jsoncpp_test = executable(
'jsoncpp_test',
[ 'src/test_lib_json/jsontest.cpp',
'src/test_lib_json/jsontest.h',
'src/test_lib_json/main.cpp'],
include_directories : jsoncpp_include_directories,
link_with : jsoncpp_lib,
install : false)
test(
'unittest_jsoncpp_test',
jsoncpp_test)
jsontestrunner = executable(
'jsontestrunner',
'src/jsontestrunner/main.cpp',
include_directories : jsoncpp_include_directories,
link_with : jsoncpp_lib,
install : false)
test(
'unittest_jsontestrunner',
python,
args : [
'-B',
join_paths(meson.current_source_dir(), 'test/runjsontests.py'),
jsontestrunner,
join_paths(meson.current_source_dir(), 'test/data')]
)

View File

@@ -1,7 +1,5 @@
prefix=@CMAKE_INSTALL_PREFIX@ libdir=@CMAKE_INSTALL_FULL_LIBDIR@
exec_prefix=${prefix} includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
libdir=${exec_prefix}/@LIBRARY_INSTALL_DIR@
includedir=${prefix}/@INCLUDE_INSTALL_DIR@
Name: jsoncpp Name: jsoncpp
Description: A C++ library for interacting with JSON Description: A C++ library for interacting with JSON

View File

@@ -1,4 +1,4 @@
# Copyright 2009 Baptiste Lepilleur # Copyright 2009 The JsonCpp Authors
# Distributed under MIT license, or public domain if desired and # Distributed under MIT license, or public domain if desired and
# recognized in your jurisdiction. # recognized in your jurisdiction.
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE # See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE

View File

@@ -1,4 +1,4 @@
# Copyright 2007 Baptiste Lepilleur # Copyright 2007 The JsonCpp Authors
# Distributed under MIT license, or public domain if desired and # Distributed under MIT license, or public domain if desired and
# recognized in your jurisdiction. # recognized in your jurisdiction.
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE # See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE

View File

@@ -1,4 +1,4 @@
# Copyright 2010 Baptiste Lepilleur # Copyright 2010 The JsonCpp Authors
# Distributed under MIT license, or public domain if desired and # Distributed under MIT license, or public domain if desired and
# recognized in your jurisdiction. # recognized in your jurisdiction.
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE # See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE

View File

@@ -1,4 +1,4 @@
# Copyright 2007 Baptiste Lepilleur # Copyright 2007 The JsonCpp Authors
# Distributed under MIT license, or public domain if desired and # Distributed under MIT license, or public domain if desired and
# recognized in your jurisdiction. # recognized in your jurisdiction.
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE # See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE

View File

@@ -1,13 +1,41 @@
if( CMAKE_COMPILER_IS_GNUCXX ) IF( CMAKE_COMPILER_IS_GNUCXX )
#Get compiler version. #Get compiler version.
execute_process( COMMAND ${CMAKE_CXX_COMPILER} -dumpversion EXECUTE_PROCESS( COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
OUTPUT_VARIABLE GNUCXX_VERSION ) OUTPUT_VARIABLE GNUCXX_VERSION )
#-Werror=* was introduced -after- GCC 4.1.2 #-Werror=* was introduced -after- GCC 4.1.2
if( GNUCXX_VERSION VERSION_GREATER 4.1.2 ) IF( GNUCXX_VERSION VERSION_GREATER 4.1.2 )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=strict-aliasing") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=strict-aliasing")
endif() ENDIF()
endif( CMAKE_COMPILER_IS_GNUCXX ) ENDIF( CMAKE_COMPILER_IS_GNUCXX )
INCLUDE(CheckIncludeFileCXX)
INCLUDE(CheckTypeSize)
INCLUDE(CheckStructHasMember)
INCLUDE(CheckCXXSymbolExists)
check_include_file_cxx(clocale HAVE_CLOCALE)
check_cxx_symbol_exists(localeconv clocale HAVE_LOCALECONV)
IF(CMAKE_VERSION VERSION_LESS 3.0.0)
# The "LANGUAGE CXX" parameter is not supported in CMake versions below 3,
# so the C compiler and header has to be used.
check_include_file(locale.h HAVE_LOCALE_H)
SET(CMAKE_EXTRA_INCLUDE_FILES locale.h)
check_type_size("struct lconv" LCONV_SIZE)
UNSET(CMAKE_EXTRA_INCLUDE_FILES)
check_struct_has_member("struct lconv" decimal_point locale.h HAVE_DECIMAL_POINT)
ELSE()
SET(CMAKE_EXTRA_INCLUDE_FILES clocale)
check_type_size(lconv LCONV_SIZE LANGUAGE CXX)
UNSET(CMAKE_EXTRA_INCLUDE_FILES)
check_struct_has_member(lconv decimal_point clocale HAVE_DECIMAL_POINT LANGUAGE CXX)
ENDIF()
IF(NOT (HAVE_CLOCALE AND HAVE_LCONV_SIZE AND HAVE_DECIMAL_POINT AND HAVE_LOCALECONV))
MESSAGE(WARNING "Locale functionality is not supported")
ADD_DEFINITIONS(-DJSONCPP_NO_LOCALE_SUPPORT)
ENDIF()
SET( JSONCPP_INCLUDE_DIR ../../include ) SET( JSONCPP_INCLUDE_DIR ../../include )
@@ -42,18 +70,23 @@ ENDIF()
IF(BUILD_SHARED_LIBS) IF(BUILD_SHARED_LIBS)
ADD_DEFINITIONS( -DJSON_DLL_BUILD ) ADD_DEFINITIONS( -DJSON_DLL_BUILD )
ADD_LIBRARY(jsoncpp_lib SHARED ${PUBLIC_HEADERS} ${jsoncpp_sources}) ADD_LIBRARY(jsoncpp_lib SHARED ${PUBLIC_HEADERS} ${jsoncpp_sources})
SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_VERSION_MAJOR}) SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_SOVERSION})
SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES OUTPUT_NAME jsoncpp SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES OUTPUT_NAME jsoncpp
DEBUG_OUTPUT_NAME jsoncpp${DEBUG_LIBNAME_SUFFIX} ) DEBUG_OUTPUT_NAME jsoncpp${DEBUG_LIBNAME_SUFFIX} )
# Set library's runtime search path on OSX
IF(APPLE)
SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES INSTALL_RPATH "@loader_path/." )
ENDIF()
INSTALL( TARGETS jsoncpp_lib ${INSTALL_EXPORT} INSTALL( TARGETS jsoncpp_lib ${INSTALL_EXPORT}
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${ARCHIVE_INSTALL_DIR}) ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
IF(NOT CMAKE_VERSION VERSION_LESS 2.8.11) IF(NOT CMAKE_VERSION VERSION_LESS 2.8.11)
TARGET_INCLUDE_DIRECTORIES( jsoncpp_lib PUBLIC TARGET_INCLUDE_DIRECTORIES( jsoncpp_lib PUBLIC
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}>) $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}>)
ENDIF() ENDIF()
@@ -61,20 +94,20 @@ ENDIF()
IF(BUILD_STATIC_LIBS) IF(BUILD_STATIC_LIBS)
ADD_LIBRARY(jsoncpp_lib_static STATIC ${PUBLIC_HEADERS} ${jsoncpp_sources}) ADD_LIBRARY(jsoncpp_lib_static STATIC ${PUBLIC_HEADERS} ${jsoncpp_sources})
SET_TARGET_PROPERTIES( jsoncpp_lib_static PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_VERSION_MAJOR}) SET_TARGET_PROPERTIES( jsoncpp_lib_static PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_SOVERSION})
SET_TARGET_PROPERTIES( jsoncpp_lib_static PROPERTIES OUTPUT_NAME jsoncpp SET_TARGET_PROPERTIES( jsoncpp_lib_static PROPERTIES OUTPUT_NAME jsoncpp
DEBUG_OUTPUT_NAME jsoncpp${DEBUG_LIBNAME_SUFFIX} ) DEBUG_OUTPUT_NAME jsoncpp${DEBUG_LIBNAME_SUFFIX} )
INSTALL( TARGETS jsoncpp_lib_static ${INSTALL_EXPORT} INSTALL( TARGETS jsoncpp_lib_static ${INSTALL_EXPORT}
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${ARCHIVE_INSTALL_DIR}) ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
IF(NOT CMAKE_VERSION VERSION_LESS 2.8.11) IF(NOT CMAKE_VERSION VERSION_LESS 2.8.11)
TARGET_INCLUDE_DIRECTORIES( jsoncpp_lib_static PUBLIC TARGET_INCLUDE_DIRECTORIES( jsoncpp_lib_static PUBLIC
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}>
) )
ENDIF() ENDIF()
ENDIF() ENDIF()

View File

@@ -1,4 +1,5 @@
// Copyright 2007-2011 Baptiste Lepilleur // Copyright 2007-2011 Baptiste Lepilleur
// Copyright (C) 2016 InfoTeCS JSC. All rights reserved.
// Distributed under MIT license, or public domain if desired and // Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction. // recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -44,8 +45,12 @@
#pragma warning(disable : 4996) #pragma warning(disable : 4996)
#endif #endif
static int const stackLimit_g = 1000; // Define JSONCPP_DEPRECATED_STACK_LIMIT as an appropriate integer at compile time to change the stack limit
static int stackDepth_g = 0; // see readValue() #if !defined(JSONCPP_DEPRECATED_STACK_LIMIT)
#define JSONCPP_DEPRECATED_STACK_LIMIT 1000
#endif
static size_t const stackLimit_g = JSONCPP_DEPRECATED_STACK_LIMIT; // see readValue()
namespace Json { namespace Json {
@@ -132,13 +137,12 @@ bool Reader::parse(const char* beginDoc,
current_ = begin_; current_ = begin_;
lastValueEnd_ = 0; lastValueEnd_ = 0;
lastValue_ = 0; lastValue_ = 0;
commentsBefore_ = ""; commentsBefore_.clear();
errors_.clear(); errors_.clear();
while (!nodes_.empty()) while (!nodes_.empty())
nodes_.pop(); nodes_.pop();
nodes_.push(&root); nodes_.push(&root);
stackDepth_g = 0; // Yes, this is bad coding, but options are limited.
bool successful = readValue(); bool successful = readValue();
Token token; Token token;
skipCommentTokens(token); skipCommentTokens(token);
@@ -161,12 +165,10 @@ bool Reader::parse(const char* beginDoc,
} }
bool Reader::readValue() { bool Reader::readValue() {
// This is a non-reentrant way to support a stackLimit. Terrible! // readValue() may call itself only if it calls readObject() or ReadArray().
// But this deprecated class has a security problem: Bad input can // These methods execute nodes_.push() just before and nodes_.pop)() just after calling readValue().
// cause a seg-fault. This seems like a fair, binary-compatible way // parse() executes one nodes_.push(), so > instead of >=.
// to prevent the problem. if (nodes_.size() > stackLimit_g) throwRuntimeError("Exceeded stackLimit in readValue().");
if (stackDepth_g >= stackLimit_g) throwRuntimeError("Exceeded stackLimit in readValue().");
++stackDepth_g;
Token token; Token token;
skipCommentTokens(token); skipCommentTokens(token);
@@ -174,7 +176,7 @@ bool Reader::readValue() {
if (collectComments_ && !commentsBefore_.empty()) { if (collectComments_ && !commentsBefore_.empty()) {
currentValue().setComment(commentsBefore_, commentBefore); currentValue().setComment(commentsBefore_, commentBefore);
commentsBefore_ = ""; commentsBefore_.clear();
} }
switch (token.type_) { switch (token.type_) {
@@ -240,7 +242,6 @@ bool Reader::readValue() {
lastValue_ = &currentValue(); lastValue_ = &currentValue();
} }
--stackDepth_g;
return successful; return successful;
} }
@@ -401,7 +402,7 @@ Reader::addComment(Location begin, Location end, CommentPlacement placement) {
} }
bool Reader::readCStyleComment() { bool Reader::readCStyleComment() {
while (current_ != end_) { while ((current_ + 1) < end_) {
Char c = getNextChar(); Char c = getNextChar();
if (c == '*' && *current_ == '/') if (c == '*' && *current_ == '/')
break; break;
@@ -473,7 +474,7 @@ bool Reader::readObject(Token& tokenStart) {
break; break;
if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
return true; return true;
name = ""; name.clear();
if (tokenName.type_ == tokenString) { if (tokenName.type_ == tokenString) {
if (!decodeString(tokenName, name)) if (!decodeString(tokenName, name))
return recoverFromError(tokenObjectEnd); return recoverFromError(tokenObjectEnd);
@@ -520,7 +521,7 @@ bool Reader::readArray(Token& tokenStart) {
currentValue().swapPayload(init); currentValue().swapPayload(init);
currentValue().setOffsetStart(tokenStart.start_ - begin_); currentValue().setOffsetStart(tokenStart.start_ - begin_);
skipSpaces(); skipSpaces();
if (*current_ == ']') // empty array if (current_ != end_ && *current_ == ']') // empty array
{ {
Token endArray; Token endArray;
readToken(endArray); readToken(endArray);
@@ -1028,7 +1029,6 @@ private:
Location lastValueEnd_; Location lastValueEnd_;
Value* lastValue_; Value* lastValue_;
JSONCPP_STRING commentsBefore_; JSONCPP_STRING commentsBefore_;
int stackDepth_;
OurFeatures const features_; OurFeatures const features_;
bool collectComments_; bool collectComments_;
@@ -1039,7 +1039,6 @@ private:
OurReader::OurReader(OurFeatures const& features) OurReader::OurReader(OurFeatures const& features)
: errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(), : errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),
lastValue_(), commentsBefore_(), lastValue_(), commentsBefore_(),
stackDepth_(0),
features_(features), collectComments_() { features_(features), collectComments_() {
} }
@@ -1057,13 +1056,12 @@ bool OurReader::parse(const char* beginDoc,
current_ = begin_; current_ = begin_;
lastValueEnd_ = 0; lastValueEnd_ = 0;
lastValue_ = 0; lastValue_ = 0;
commentsBefore_ = ""; commentsBefore_.clear();
errors_.clear(); errors_.clear();
while (!nodes_.empty()) while (!nodes_.empty())
nodes_.pop(); nodes_.pop();
nodes_.push(&root); nodes_.push(&root);
stackDepth_ = 0;
bool successful = readValue(); bool successful = readValue();
Token token; Token token;
skipCommentTokens(token); skipCommentTokens(token);
@@ -1092,15 +1090,15 @@ bool OurReader::parse(const char* beginDoc,
} }
bool OurReader::readValue() { bool OurReader::readValue() {
if (stackDepth_ >= features_.stackLimit_) throwRuntimeError("Exceeded stackLimit in readValue()."); // To preserve the old behaviour we cast size_t to int.
++stackDepth_; if (static_cast<int>(nodes_.size()) > features_.stackLimit_) throwRuntimeError("Exceeded stackLimit in readValue().");
Token token; Token token;
skipCommentTokens(token); skipCommentTokens(token);
bool successful = true; bool successful = true;
if (collectComments_ && !commentsBefore_.empty()) { if (collectComments_ && !commentsBefore_.empty()) {
currentValue().setComment(commentsBefore_, commentBefore); currentValue().setComment(commentsBefore_, commentBefore);
commentsBefore_ = ""; commentsBefore_.clear();
} }
switch (token.type_) { switch (token.type_) {
@@ -1190,7 +1188,6 @@ bool OurReader::readValue() {
lastValue_ = &currentValue(); lastValue_ = &currentValue();
} }
--stackDepth_;
return successful; return successful;
} }
@@ -1361,7 +1358,7 @@ OurReader::addComment(Location begin, Location end, CommentPlacement placement)
} }
bool OurReader::readCStyleComment() { bool OurReader::readCStyleComment() {
while (current_ != end_) { while ((current_ + 1) < end_) {
Char c = getNextChar(); Char c = getNextChar();
if (c == '*' && *current_ == '/') if (c == '*' && *current_ == '/')
break; break;
@@ -1450,7 +1447,7 @@ bool OurReader::readObject(Token& tokenStart) {
break; break;
if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
return true; return true;
name = ""; name.clear();
if (tokenName.type_ == tokenString) { if (tokenName.type_ == tokenString) {
if (!decodeString(tokenName, name)) if (!decodeString(tokenName, name))
return recoverFromError(tokenObjectEnd); return recoverFromError(tokenObjectEnd);
@@ -1503,7 +1500,7 @@ bool OurReader::readArray(Token& tokenStart) {
currentValue().swapPayload(init); currentValue().swapPayload(init);
currentValue().setOffsetStart(tokenStart.start_ - begin_); currentValue().setOffsetStart(tokenStart.start_ - begin_);
skipSpaces(); skipSpaces();
if (*current_ == ']') // empty array if (current_ != end_ && *current_ == ']') // empty array
{ {
Token endArray; Token endArray;
readToken(endArray); readToken(endArray);

View File

@@ -5,7 +5,16 @@
#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED #ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED
#define LIB_JSONCPP_JSON_TOOL_H_INCLUDED #define LIB_JSONCPP_JSON_TOOL_H_INCLUDED
// Also support old flag NO_LOCALE_SUPPORT
#ifdef NO_LOCALE_SUPPORT
#define JSONCPP_NO_LOCALE_SUPPORT
#endif
#ifndef JSONCPP_NO_LOCALE_SUPPORT
#include <clocale> #include <clocale>
#endif
/* This header provides common string manipulation support, such as UTF-8, /* This header provides common string manipulation support, such as UTF-8,
* portable conversion from/to string... * portable conversion from/to string...
@@ -14,26 +23,14 @@
*/ */
namespace Json { namespace Json {
static char getDecimalPoint() {
/// Fallback for decimal_point on android, where the lconv is an empty struct. #ifdef JSONCPP_NO_LOCALE_SUPPORT
template<typename Lconv, bool=(sizeof(Lconv) >= sizeof(char*))> return '\0';
struct Locale { #else
static char decimalPoint() { struct lconv* lc = localeconv();
return '\0'; return lc ? *(lc->decimal_point) : '\0';
} #endif
}; }
/// Return decimal_point for the current locale.
template<typename Lconv>
struct Locale<Lconv, true> {
static char decimalPoint() {
Lconv* lc = localeconv();
if (lc == NULL) {
return '\0';
}
return *(lc->decimal_point);
}
};
/// Converts a unicode code-point to UTF-8. /// Converts a unicode code-point to UTF-8.
static inline JSONCPP_STRING codePointToUTF8(unsigned int cp) { static inline JSONCPP_STRING codePointToUTF8(unsigned int cp) {
@@ -104,7 +101,7 @@ static inline void fixNumericLocale(char* begin, char* end) {
} }
static inline void fixNumericLocaleInput(char* begin, char* end) { static inline void fixNumericLocaleInput(char* begin, char* end) {
char decimalPoint = Locale<struct lconv>::decimalPoint(); char decimalPoint = getDecimalPoint();
if (decimalPoint != '\0' && decimalPoint != '.') { if (decimalPoint != '\0' && decimalPoint != '.') {
while (begin < end) { while (begin < end) {
if (*begin == '.') { if (*begin == '.') {

View File

@@ -193,9 +193,9 @@ namespace Json {
Exception::Exception(JSONCPP_STRING const& msg) Exception::Exception(JSONCPP_STRING const& msg)
: msg_(msg) : msg_(msg)
{} {}
Exception::~Exception() throw() Exception::~Exception() JSONCPP_NOEXCEPT
{} {}
char const* Exception::what() const throw() char const* Exception::what() const JSONCPP_NOEXCEPT
{ {
return msg_.c_str(); return msg_.c_str();
} }
@@ -303,7 +303,7 @@ bool Value::CZString::operator<(const CZString& other) const {
// Assume both are strings. // Assume both are strings.
unsigned this_len = this->storage_.length_; unsigned this_len = this->storage_.length_;
unsigned other_len = other.storage_.length_; unsigned other_len = other.storage_.length_;
unsigned min_len = std::min(this_len, other_len); unsigned min_len = std::min<unsigned>(this_len, other_len);
JSON_ASSERT(this->cstr_ && other.cstr_); JSON_ASSERT(this->cstr_ && other.cstr_);
int comp = memcmp(this->cstr_, other.cstr_, min_len); int comp = memcmp(this->cstr_, other.cstr_, min_len);
if (comp < 0) return true; if (comp < 0) return true;
@@ -343,7 +343,7 @@ bool Value::CZString::isStaticString() const { return storage_.policy_ == noDupl
* This optimization is used in ValueInternalMap fast allocator. * This optimization is used in ValueInternalMap fast allocator.
*/ */
Value::Value(ValueType vtype) { Value::Value(ValueType vtype) {
static char const empty[] = ""; static char const emptyString[] = "";
initBasic(vtype); initBasic(vtype);
switch (vtype) { switch (vtype) {
case nullValue: case nullValue:
@@ -357,7 +357,7 @@ Value::Value(ValueType vtype) {
break; break;
case stringValue: case stringValue:
// allocated_ == false, so this is safe. // allocated_ == false, so this is safe.
value_.string_ = const_cast<char*>(static_cast<char const*>(empty)); value_.string_ = const_cast<char*>(static_cast<char const*>(emptyString));
break; break;
case arrayValue: case arrayValue:
case objectValue: case objectValue:
@@ -398,6 +398,7 @@ Value::Value(double value) {
Value::Value(const char* value) { Value::Value(const char* value) {
initBasic(stringValue, true); initBasic(stringValue, true);
JSON_ASSERT_MESSAGE(value != NULL, "Null Value Passed to Value Constructor");
value_.string_ = duplicateAndPrefixStringValue(value, static_cast<unsigned>(strlen(value))); value_.string_ = duplicateAndPrefixStringValue(value, static_cast<unsigned>(strlen(value)));
} }
@@ -566,7 +567,7 @@ bool Value::operator<(const Value& other) const {
char const* other_str; char const* other_str;
decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str); decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
decodePrefixedString(other.allocated_, other.value_.string_, &other_len, &other_str); decodePrefixedString(other.allocated_, other.value_.string_, &other_len, &other_str);
unsigned min_len = std::min(this_len, other_len); unsigned min_len = std::min<unsigned>(this_len, other_len);
JSON_ASSERT(this_str && other_str); JSON_ASSERT(this_str && other_str);
int comp = memcmp(this_str, other_str, min_len); int comp = memcmp(this_str, other_str, min_len);
if (comp < 0) return true; if (comp < 0) return true;
@@ -879,7 +880,7 @@ bool Value::isConvertibleTo(ValueType other) const {
case nullValue: case nullValue:
return (isNumeric() && asDouble() == 0.0) || return (isNumeric() && asDouble() == 0.0) ||
(type_ == booleanValue && value_.bool_ == false) || (type_ == booleanValue && value_.bool_ == false) ||
(type_ == stringValue && asString() == "") || (type_ == stringValue && asString().empty()) ||
(type_ == arrayValue && value_.map_->size() == 0) || (type_ == arrayValue && value_.map_->size() == 0) ||
(type_ == objectValue && value_.map_->size() == 0) || (type_ == objectValue && value_.map_->size() == 0) ||
type_ == nullValue; type_ == nullValue;
@@ -1279,7 +1280,11 @@ bool Value::isBool() const { return type_ == booleanValue; }
bool Value::isInt() const { bool Value::isInt() const {
switch (type_) { switch (type_) {
case intValue: case intValue:
#if defined(JSON_HAS_INT64)
return value_.int_ >= minInt && value_.int_ <= maxInt; return value_.int_ >= minInt && value_.int_ <= maxInt;
#else
return true;
#endif
case uintValue: case uintValue:
return value_.uint_ <= UInt(maxInt); return value_.uint_ <= UInt(maxInt);
case realValue: case realValue:
@@ -1294,9 +1299,17 @@ bool Value::isInt() const {
bool Value::isUInt() const { bool Value::isUInt() const {
switch (type_) { switch (type_) {
case intValue: case intValue:
#if defined(JSON_HAS_INT64)
return value_.int_ >= 0 && LargestUInt(value_.int_) <= LargestUInt(maxUInt); return value_.int_ >= 0 && LargestUInt(value_.int_) <= LargestUInt(maxUInt);
#else
return value_.int_ >= 0;
#endif
case uintValue: case uintValue:
#if defined(JSON_HAS_INT64)
return value_.uint_ <= maxUInt; return value_.uint_ <= maxUInt;
#else
return true;
#endif
case realValue: case realValue:
return value_.real_ >= 0 && value_.real_ <= maxUInt && return value_.real_ >= 0 && value_.real_ <= maxUInt &&
IsIntegral(value_.real_); IsIntegral(value_.real_);
@@ -1347,16 +1360,28 @@ bool Value::isUInt64() const {
} }
bool Value::isIntegral() const { bool Value::isIntegral() const {
switch (type_) {
case intValue:
case uintValue:
return true;
case realValue:
#if defined(JSON_HAS_INT64) #if defined(JSON_HAS_INT64)
return isInt64() || isUInt64(); // Note that maxUInt64 (= 2^64 - 1) is not exactly representable as a
// double, so double(maxUInt64) will be rounded up to 2^64. Therefore we
// require the value to be strictly less than the limit.
return value_.real_ >= double(minInt64) && value_.real_ < maxUInt64AsDouble && IsIntegral(value_.real_);
#else #else
return isInt() || isUInt(); return value_.real_ >= minInt && value_.real_ <= maxUInt && IsIntegral(value_.real_);
#endif #endif // JSON_HAS_INT64
default:
break;
}
return false;
} }
bool Value::isDouble() const { return type_ == realValue || isIntegral(); } bool Value::isDouble() const { return type_ == intValue || type_ == uintValue || type_ == realValue; }
bool Value::isNumeric() const { return isIntegral() || isDouble(); } bool Value::isNumeric() const { return isDouble(); }
bool Value::isString() const { return type_ == stringValue; } bool Value::isString() const { return type_ == stringValue; }
@@ -1481,6 +1506,7 @@ Path::Path(const JSONCPP_STRING& path,
const PathArgument& a4, const PathArgument& a4,
const PathArgument& a5) { const PathArgument& a5) {
InArgs in; InArgs in;
in.reserve(5);
in.push_back(&a1); in.push_back(&a1);
in.push_back(&a2); in.push_back(&a2);
in.push_back(&a3); in.push_back(&a3);
@@ -1504,12 +1530,12 @@ void Path::makePath(const JSONCPP_STRING& path, const InArgs& in) {
index = index * 10 + ArrayIndex(*current - '0'); index = index * 10 + ArrayIndex(*current - '0');
args_.push_back(index); args_.push_back(index);
} }
if (current == end || *current++ != ']') if (current == end || *++current != ']')
invalidPath(path, int(current - path.c_str())); invalidPath(path, int(current - path.c_str()));
} else if (*current == '%') { } else if (*current == '%') {
addPathInArg(path, in, itInArg, PathArgument::kindKey); addPathInArg(path, in, itInArg, PathArgument::kindKey);
++current; ++current;
} else if (*current == '.') { } else if (*current == '.' || *current == ']') {
++current; ++current;
} else { } else {
const char* beginName = current; const char* beginName = current;
@@ -1529,7 +1555,7 @@ void Path::addPathInArg(const JSONCPP_STRING& /*path*/,
} else if ((*itInArg)->kind_ != kind) { } else if ((*itInArg)->kind_ != kind) {
// Error: bad argument type // Error: bad argument type
} else { } else {
args_.push_back(**itInArg); args_.push_back(**itInArg++);
} }
} }
@@ -1544,16 +1570,19 @@ const Value& Path::resolve(const Value& root) const {
if (arg.kind_ == PathArgument::kindIndex) { if (arg.kind_ == PathArgument::kindIndex) {
if (!node->isArray() || !node->isValidIndex(arg.index_)) { if (!node->isArray() || !node->isValidIndex(arg.index_)) {
// Error: unable to resolve path (array value expected at position... // Error: unable to resolve path (array value expected at position...
return Value::null;
} }
node = &((*node)[arg.index_]); node = &((*node)[arg.index_]);
} else if (arg.kind_ == PathArgument::kindKey) { } else if (arg.kind_ == PathArgument::kindKey) {
if (!node->isObject()) { if (!node->isObject()) {
// Error: unable to resolve path (object value expected at position...) // Error: unable to resolve path (object value expected at position...)
return Value::null;
} }
node = &((*node)[arg.key_]); node = &((*node)[arg.key_]);
if (node == &Value::nullSingleton()) { if (node == &Value::nullSingleton()) {
// Error: unable to resolve path (object has no member named '' at // Error: unable to resolve path (object has no member named '' at
// position...) // position...)
return Value::null;
} }
} }
} }

View File

@@ -139,17 +139,24 @@ namespace {
JSONCPP_STRING valueToString(double value, bool useSpecialFloats, unsigned int precision) { JSONCPP_STRING valueToString(double value, bool useSpecialFloats, unsigned int precision) {
// Allocate a buffer that is more than large enough to store the 16 digits of // Allocate a buffer that is more than large enough to store the 16 digits of
// precision requested below. // precision requested below.
char buffer[32]; char buffer[36];
int len = -1; int len = -1;
char formatString[6]; char formatString[15];
sprintf(formatString, "%%.%dg", precision); snprintf(formatString, sizeof(formatString), "%%.%dg", precision);
// Print into the buffer. We need not request the alternative representation // Print into the buffer. We need not request the alternative representation
// that always has a decimal point because JSON doesn't distingish the // that always has a decimal point because JSON doesn't distingish the
// concepts of reals and integers. // concepts of reals and integers.
if (isfinite(value)) { if (isfinite(value)) {
len = snprintf(buffer, sizeof(buffer), formatString, value); len = snprintf(buffer, sizeof(buffer), formatString, value);
fixNumericLocale(buffer, buffer + len);
// try to ensure we preserve the fact that this was given to us as a double on input
if (!strstr(buffer, ".") && !strstr(buffer, "e")) {
strcat(buffer, ".0");
}
} else { } else {
// IEEE standard states that NaN values will not compare to themselves // IEEE standard states that NaN values will not compare to themselves
if (value != value) { if (value != value) {
@@ -159,10 +166,8 @@ JSONCPP_STRING valueToString(double value, bool useSpecialFloats, unsigned int p
} else { } else {
len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "Infinity" : "1e+9999"); len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "Infinity" : "1e+9999");
} }
// For those, we do not need to call fixNumLoc, but it is fast.
} }
assert(len >= 0); assert(len >= 0);
fixNumericLocale(buffer, buffer + len);
return buffer; return buffer;
} }
} }
@@ -329,7 +334,7 @@ void FastWriter::dropNullPlaceholders() { dropNullPlaceholders_ = true; }
void FastWriter::omitEndingLineFeed() { omitEndingLineFeed_ = true; } void FastWriter::omitEndingLineFeed() { omitEndingLineFeed_ = true; }
JSONCPP_STRING FastWriter::write(const Value& root) { JSONCPP_STRING FastWriter::write(const Value& root) {
document_ = ""; document_.clear();
writeValue(root); writeValue(root);
if (!omitEndingLineFeed_) if (!omitEndingLineFeed_)
document_ += "\n"; document_ += "\n";
@@ -397,9 +402,9 @@ StyledWriter::StyledWriter()
: rightMargin_(74), indentSize_(3), addChildValues_() {} : rightMargin_(74), indentSize_(3), addChildValues_() {}
JSONCPP_STRING StyledWriter::write(const Value& root) { JSONCPP_STRING StyledWriter::write(const Value& root) {
document_ = ""; document_.clear();
addChildValues_ = false; addChildValues_ = false;
indentString_ = ""; indentString_.clear();
writeCommentBeforeValue(root); writeCommentBeforeValue(root);
writeValue(root); writeValue(root);
writeCommentAfterValueOnSameLine(root); writeCommentAfterValueOnSameLine(root);
@@ -613,7 +618,7 @@ StyledStreamWriter::StyledStreamWriter(JSONCPP_STRING indentation)
void StyledStreamWriter::write(JSONCPP_OSTREAM& out, const Value& root) { void StyledStreamWriter::write(JSONCPP_OSTREAM& out, const Value& root) {
document_ = &out; document_ = &out;
addChildValues_ = false; addChildValues_ = false;
indentString_ = ""; indentString_.clear();
indented_ = true; indented_ = true;
writeCommentBeforeValue(root); writeCommentBeforeValue(root);
if (!indented_) writeIndent(); if (!indented_) writeIndent();
@@ -895,7 +900,7 @@ int BuiltStyledStreamWriter::write(Value const& root, JSONCPP_OSTREAM* sout)
sout_ = sout; sout_ = sout;
addChildValues_ = false; addChildValues_ = false;
indented_ = true; indented_ = true;
indentString_ = ""; indentString_.clear();
writeCommentBeforeValue(root); writeCommentBeforeValue(root);
if (!indented_) writeIndent(); if (!indented_) writeIndent();
indented_ = true; indented_ = true;
@@ -1149,10 +1154,10 @@ StreamWriter* StreamWriterBuilder::newStreamWriter() const
} }
JSONCPP_STRING nullSymbol = "null"; JSONCPP_STRING nullSymbol = "null";
if (dnp) { if (dnp) {
nullSymbol = ""; nullSymbol.clear();
} }
if (pre > 17) pre = 17; if (pre > 17) pre = 17;
JSONCPP_STRING endingLineFeedSymbol = ""; JSONCPP_STRING endingLineFeedSymbol;
return new BuiltStyledStreamWriter( return new BuiltStyledStreamWriter(
indentation, cs, indentation, cs,
colonSymbol, nullSymbol, endingLineFeedSymbol, usf, pre); colonSymbol, nullSymbol, endingLineFeedSymbol, usf, pre);

View File

@@ -479,7 +479,7 @@ JSONTEST_FIXTURE(ValueTest, integers) {
JSONTEST_ASSERT_EQUAL(0.0, val.asDouble()); JSONTEST_ASSERT_EQUAL(0.0, val.asDouble());
JSONTEST_ASSERT_EQUAL(0.0, val.asFloat()); JSONTEST_ASSERT_EQUAL(0.0, val.asFloat());
JSONTEST_ASSERT_EQUAL(false, val.asBool()); JSONTEST_ASSERT_EQUAL(false, val.asBool());
JSONTEST_ASSERT_STRING_EQUAL("0", val.asString()); JSONTEST_ASSERT_STRING_EQUAL("0.0", val.asString());
// Zero (signed constructor arg) // Zero (signed constructor arg)
val = Json::Value(0); val = Json::Value(0);
@@ -563,7 +563,7 @@ JSONTEST_FIXTURE(ValueTest, integers) {
JSONTEST_ASSERT_EQUAL(0.0, val.asDouble()); JSONTEST_ASSERT_EQUAL(0.0, val.asDouble());
JSONTEST_ASSERT_EQUAL(0.0, val.asFloat()); JSONTEST_ASSERT_EQUAL(0.0, val.asFloat());
JSONTEST_ASSERT_EQUAL(false, val.asBool()); JSONTEST_ASSERT_EQUAL(false, val.asBool());
JSONTEST_ASSERT_STRING_EQUAL("0", val.asString()); JSONTEST_ASSERT_STRING_EQUAL("0.0", val.asString());
// 2^20 (signed constructor arg) // 2^20 (signed constructor arg)
val = Json::Value(1 << 20); val = Json::Value(1 << 20);
@@ -646,7 +646,7 @@ JSONTEST_FIXTURE(ValueTest, integers) {
JSONTEST_ASSERT_EQUAL((1 << 20), val.asDouble()); JSONTEST_ASSERT_EQUAL((1 << 20), val.asDouble());
JSONTEST_ASSERT_EQUAL((1 << 20), val.asFloat()); JSONTEST_ASSERT_EQUAL((1 << 20), val.asFloat());
JSONTEST_ASSERT_EQUAL(true, val.asBool()); JSONTEST_ASSERT_EQUAL(true, val.asBool());
JSONTEST_ASSERT_STRING_EQUAL("1048576", JSONTEST_ASSERT_STRING_EQUAL("1048576.0",
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString()))); normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
// -2^20 // -2^20
@@ -887,7 +887,7 @@ JSONTEST_FIXTURE(ValueTest, integers) {
JSONTEST_ASSERT_EQUAL((Json::Int64(1) << 40), val.asDouble()); JSONTEST_ASSERT_EQUAL((Json::Int64(1) << 40), val.asDouble());
JSONTEST_ASSERT_EQUAL((Json::Int64(1) << 40), val.asFloat()); JSONTEST_ASSERT_EQUAL((Json::Int64(1) << 40), val.asFloat());
JSONTEST_ASSERT_EQUAL(true, val.asBool()); JSONTEST_ASSERT_EQUAL(true, val.asBool());
JSONTEST_ASSERT_STRING_EQUAL("1099511627776", JSONTEST_ASSERT_STRING_EQUAL("1099511627776.0",
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString()))); normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
// -2^40 // -2^40
@@ -1259,7 +1259,7 @@ JSONTEST_FIXTURE(ValueTest, nonIntegers) {
// A 16-digit floating point number. // A 16-digit floating point number.
val = Json::Value(2199023255552000.0f); val = Json::Value(2199023255552000.0f);
JSONTEST_ASSERT_EQUAL(float(2199023255552000.0f), val.asFloat()); JSONTEST_ASSERT_EQUAL(float(2199023255552000.0f), val.asFloat());
JSONTEST_ASSERT_STRING_EQUAL("2199023255552000", JSONTEST_ASSERT_STRING_EQUAL("2199023255552000.0",
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString()))); normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
// A very large floating point number. // A very large floating point number.

View File

@@ -1,4 +1,4 @@
# Copyright 2007 Baptiste Lepilleur # Copyright 2007 The JsonCpp Authors
# Distributed under MIT license, or public domain if desired and # Distributed under MIT license, or public domain if desired and
# recognized in your jurisdiction. # recognized in your jurisdiction.
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE # See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE

View File

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

View File

@@ -1,4 +1,4 @@
# Copyright 2007 Baptiste Lepilleur # Copyright 2007 The JsonCpp Authors
# Distributed under MIT license, or public domain if desired and # Distributed under MIT license, or public domain if desired and
# recognized in your jurisdiction. # recognized in your jurisdiction.
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE # See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE

View File

@@ -1,4 +1,4 @@
# Copyright 2007 Baptiste Lepilleur # Copyright 2007 The JsonCpp Authors
# Distributed under MIT license, or public domain if desired and # Distributed under MIT license, or public domain if desired and
# recognized in your jurisdiction. # recognized in your jurisdiction.
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE # See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE

View File

@@ -1,4 +1,4 @@
# Copyright 2007 Baptiste Lepilleur # Copyright 2007 The JsonCpp Authors
# Distributed under MIT license, or public domain if desired and # Distributed under MIT license, or public domain if desired and
# recognized in your jurisdiction. # recognized in your jurisdiction.
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE # See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE

View File

@@ -1,4 +1,4 @@
# Copyright 2009 Baptiste Lepilleur # Copyright 2009 The JsonCpp Authors
# Distributed under MIT license, or public domain if desired and # Distributed under MIT license, or public domain if desired and
# recognized in your jurisdiction. # recognized in your jurisdiction.
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE # See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE

View File

@@ -17,15 +17,7 @@ set -vex
env | sort env | sort
cmake -DJSONCPP_WITH_CMAKE_PACKAGE=$CMAKE_PKG -DBUILD_SHARED_LIBS=$SHARED_LIB -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_VERBOSE_MAKEFILE=$VERBOSE_MAKE . meson --buildtype ${BUILD_TYPE} --default-library ${LIB_TYPE} . build-${LIB_TYPE}
make ninja -v -C build-${LIB_TYPE}
cmake -DJSONCPP_WITH_CMAKE_PACKAGE=$CMAKE_PKG -DBUILD_SHARED_LIBS=$SHARED_LIB -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_VERBOSE_MAKEFILE=$VERBOSE_MAKE -DJSONCPP_USE_SECURE_MEMORY=1 . ninja -v -C build-${LIB_TYPE} test
make rm -r build-${LIB_TYPE}
# Python is not available in Travis for osx.
# https://github.com/travis-ci/travis-ci/issues/2320
if [ "$TRAVIS_OS_NAME" != "osx" ]
then
make jsoncpp_check
valgrind --error-exitcode=42 --leak-check=full ./src/test_lib_json/jsoncpp_test
fi

View File

@@ -1 +1 @@
1.7.5 1.8.1