Skip to content
This repository was archived by the owner on Jul 3, 2020. It is now read-only.

Commit 94e67e3

Browse files
author
Face Kapow
committed
Merge commit 'be61c553c20aef4dc530234a7dfb4dcac25c68d8' as 'deps/json11'
2 parents 7299d5e + be61c55 commit 94e67e3

File tree

9 files changed

+1410
-0
lines changed

9 files changed

+1410
-0
lines changed

deps/json11/.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# generated files
2+
test
3+
libjson11.a
4+
json11.pc
5+
6+
# Cmake
7+
CMakeCache.txt
8+
CTestTestfile.cmake
9+
CMakeFiles
10+
CMakeScripts
11+
cmake_install.cmake
12+
install_manifest.txt

deps/json11/CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
cmake_minimum_required(VERSION 3.2)
2+
project(json11 VERSION 1.0.0 LANGUAGES CXX)
3+
4+
enable_testing()
5+
6+
option(JSON11_BUILD_TESTS "Build unit tests" ON)
7+
8+
add_library(json11 json11.cpp)
9+
target_include_directories(json11 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
10+
target_compile_options(json11
11+
PUBLIC -std=c++11
12+
PRIVATE -fno-rtti -fno-exceptions -Wall -Wextra -Werror)
13+
configure_file("json11.pc.in" "json11.pc" @ONLY)
14+
15+
if (JSON11_BUILD_TESTS)
16+
add_executable(json11_test test.cpp)
17+
target_link_libraries(json11_test json11)
18+
endif()
19+
20+
install(TARGETS json11 DESTINATION lib)
21+
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/json11.hpp" DESTINATION include)
22+
install(FILES "${CMAKE_BINARY_DIR}/json11.pc" DESTINATION lib/pkgconfig)

deps/json11/LICENSE.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2013 Dropbox, Inc.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

deps/json11/Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Environment variable to enable or disable code which demonstrates the behavior change
2+
# in Xcode 7 / Clang 3.7, introduced by DR1467 and described here:
3+
# https://llvm.org/bugs/show_bug.cgi?id=23812
4+
# Defaults to on in order to act as a warning to anyone who's unaware of the issue.
5+
ifneq ($(JSON11_ENABLE_DR1467_CANARY),)
6+
CANARY_ARGS = -DJSON11_ENABLE_DR1467_CANARY=$(JSON11_ENABLE_DR1467_CANARY)
7+
endif
8+
9+
test: json11.cpp json11.hpp test.cpp
10+
$(CXX) $(CANARY_ARGS) -O -std=c++11 json11.cpp test.cpp -o test -fno-rtti -fno-exceptions
11+
12+
clean:
13+
if [ -e test ]; then rm test; fi
14+
15+
.PHONY: clean

deps/json11/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
json11
2+
------
3+
4+
json11 is a tiny JSON library for C++11, providing JSON parsing and serialization.
5+
6+
The core object provided by the library is json11::Json. A Json object represents any JSON
7+
value: null, bool, number (int or double), string (std::string), array (std::vector), or
8+
object (std::map).
9+
10+
Json objects act like values. They can be assigned, copied, moved, compared for equality or
11+
order, and so on. There are also helper methods Json::dump, to serialize a Json to a string, and
12+
Json::parse (static) to parse a std::string as a Json object.
13+
14+
It's easy to make a JSON object with C++11's new initializer syntax:
15+
16+
Json my_json = Json::object {
17+
{ "key1", "value1" },
18+
{ "key2", false },
19+
{ "key3", Json::array { 1, 2, 3 } },
20+
};
21+
std::string json_str = my_json.dump();
22+
23+
There are also implicit constructors that allow standard and user-defined types to be
24+
automatically converted to JSON. For example:
25+
26+
class Point {
27+
public:
28+
int x;
29+
int y;
30+
Point (int x, int y) : x(x), y(y) {}
31+
Json to_json() const { return Json::array { x, y }; }
32+
};
33+
34+
std::vector<Point> points = { { 1, 2 }, { 10, 20 }, { 100, 200 } };
35+
std::string points_json = Json(points).dump();
36+
37+
JSON values can have their values queried and inspected:
38+
39+
Json json = Json::array { Json::object { { "k", "v" } } };
40+
std::string str = json[0]["k"].string_value();
41+
42+
More documentation is still to come. For now, see json11.hpp.

0 commit comments

Comments
 (0)