Unverified Commit 4f8fba14 authored by Niels Lohmann's avatar Niels Lohmann

Merge branch 'release/3.10.5'

parents fec56a1a b5364faf
Checks: '*,
-altera-id-dependent-backward-branch,
-altera-struct-pack-align,
-altera-unroll-loops,
-android-cloexec-fopen,
-bugprone-easily-swappable-parameters,
-concurrency-mt-unsafe,
-cppcoreguidelines-avoid-goto,
-cppcoreguidelines-avoid-magic-numbers,
......@@ -11,6 +14,7 @@ Checks: '*,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-pro-type-reinterpret-cast,
-cppcoreguidelines-pro-type-union-access,
-cppcoreguidelines-virtual-class-destructor,
-fuchsia-default-arguments-calls,
-fuchsia-default-arguments-declarations,
-fuchsia-overloaded-operator,
......@@ -30,9 +34,12 @@ Checks: '*,
-llvmlibc-*,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
-modernize-concat-nested-namespaces,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-readability-function-size,
-readability-function-cognitive-complexity,
-readability-function-size,
-readability-identifier-length,
-readability-magic-numbers,
-readability-redundant-access-specifiers,
-readability-uppercase-literal-suffix'
......
......@@ -47,7 +47,7 @@ assignees: ''
<!-- Please add an `x` to the respective line. -->
- [ ] latest release version 3.10.4
- [ ] latest release version 3.10.5
- [ ] other release - please state the version: ___
- [ ] the `develop` branch
......
......@@ -11,7 +11,7 @@ on:
jobs:
ci_test_clang:
runs-on: ubuntu-latest
container: ghcr.io/nlohmann/json-ci:v1.0.0
container: ghcr.io/nlohmann/json-ci:v2.2.0
steps:
- uses: actions/checkout@v2
- name: cmake
......@@ -21,7 +21,7 @@ jobs:
ci_test_gcc:
runs-on: ubuntu-latest
container: ghcr.io/nlohmann/json-ci:v1.0.0
container: ghcr.io/nlohmann/json-ci:v2.2.0
steps:
- uses: actions/checkout@v2
- name: cmake
......@@ -31,7 +31,7 @@ jobs:
ci_static_analysis:
runs-on: ubuntu-latest
container: ghcr.io/nlohmann/json-ci:v1.0.0
container: ghcr.io/nlohmann/json-ci:v2.2.0
strategy:
matrix:
target: [ci_clang_tidy, ci_cppcheck, ci_test_valgrind, ci_test_clang_sanitizer, ci_test_amalgamation, ci_clang_analyze, ci_cpplint, ci_cmake_flags, ci_single_binaries, ci_reproducible_tests, ci_non_git_tests, ci_offline_testdata, ci_infer]
......@@ -44,7 +44,7 @@ jobs:
ci_cmake_options:
runs-on: ubuntu-latest
container: ghcr.io/nlohmann/json-ci:v1.0.0
container: ghcr.io/nlohmann/json-ci:v2.2.0
strategy:
matrix:
target: [ci_test_diagnostics, ci_test_noexceptions, ci_test_noimplicitconversions]
......@@ -57,7 +57,7 @@ jobs:
ci_test_coverage:
runs-on: ubuntu-latest
container: ghcr.io/nlohmann/json-ci:v1.0.0
container: ghcr.io/nlohmann/json-ci:v2.2.0
steps:
- uses: actions/checkout@v2
- name: cmake
......@@ -77,10 +77,10 @@ jobs:
ci_test_compilers:
runs-on: ubuntu-latest
container: ghcr.io/nlohmann/json-ci:v1.0.0
container: ghcr.io/nlohmann/json-ci:v2.2.0
strategy:
matrix:
compiler: [g++-4.8, g++-4.9, g++-5, g++-7, g++-8, g++-9, g++-10, clang++-3.5, clang++-3.6, clang++-3.7, clang++-3.8, clang++-3.9, clang++-4.0, clang++-5.0, clang++-6.0, clang++-7, clang++-8, clang++-9, clang++-10, clang++-11, clang++-12]
compiler: [g++-4.8, g++-4.9, g++-5, g++-6, g++-7, g++-8, g++-9, g++-10, clang++-3.5, clang++-3.6, clang++-3.7, clang++-3.8, clang++-3.9, clang++-4.0, clang++-5.0, clang++-6.0, clang++-7, clang++-8, clang++-9, clang++-10, clang++-11, clang++-12, clang++-13]
steps:
- uses: actions/checkout@v2
- name: cmake
......@@ -90,7 +90,7 @@ jobs:
ci_test_standards:
runs-on: ubuntu-latest
container: ghcr.io/nlohmann/json-ci:v1.0.0
container: ghcr.io/nlohmann/json-ci:v2.2.0
strategy:
matrix:
standard: [11, 14, 17, 20]
......@@ -101,3 +101,13 @@ jobs:
run: cmake -S . -B build -DJSON_CI=On
- name: build
run: cmake --build build --target ci_test_${{ matrix.compiler }}_cxx${{ matrix.standard }}
ci_cuda_example:
runs-on: ubuntu-latest
container: ghcr.io/nlohmann/json-ci:v2.2.0
steps:
- uses: actions/checkout@v2
- name: cmake
run: cmake -S . -B build -DJSON_CI=On
- name: build
run: cmake --build build --target ci_cuda_example
......@@ -25,7 +25,6 @@ test/test-*
doc/html
doc/mkdocs/venv/
doc/mkdocs/docs/images
doc/mkdocs/docs/examples
doc/mkdocs/site
doc/mkdocs/docs/__pycache__/
......
#########################
# project configuration #
#########################
# C++ project
language: cpp
dist: trusty
sudo: required
group: edge
################
# build matrix #
################
matrix:
include:
# Coverity (only for branch coverity_scan)
- os: linux
compiler: clang
before_install: echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-certificates.crt
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
packages: ['g++-6', 'clang-3.6', 'ninja-build']
coverity_scan:
project:
name: "nlohmann/json"
description: "Build submitted via Travis CI"
notification_email: niels.lohmann@gmail.com
build_command_prepend: "mkdir coverity_build ; cd coverity_build ; cmake .. ; cd .."
build_command: "make -C coverity_build"
branch_pattern: coverity_scan
env:
- SPECIAL=coverity
- COMPILER=clang++-3.6
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
- secure: "m89SSgE+ASLO38rSKx7MTXK3n5NkP9bIx95jwY71YEiuFzib30PDJ/DifKnXxBjvy/AkCGztErQRk/8ZCvq+4HXozU2knEGnL/RUitvlwbhzfh2D4lmS3BvWBGS3N3NewoPBrRmdcvnT0xjOGXxtZaJ3P74TkB9GBnlz/HmKORA="
# OSX / Clang
- os: osx
osx_image: xcode10.2
# Linux / GCC
- os: linux
compiler: gcc
env: COMPILER=g++-6
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-6', 'ninja-build']
################
# build script #
################
script:
# get CMake and Ninja (only for systems with brew - macOS)
- |
if [[ (-x $(which brew)) ]]; then
brew update
brew install cmake ninja
brew upgrade cmake
cmake --version
fi
# make sure CXX is correctly set
- if [[ "${COMPILER}" != "" ]]; then export CXX=${COMPILER}; fi
# append CXX_STANDARD to CMAKE_OPTIONS if required
- CMAKE_OPTIONS+=${CXX_STANDARD:+ -DCMAKE_CXX_STANDARD=$CXX_STANDARD -DCMAKE_CXX_STANDARD_REQUIRED=ON}
# build configuration
- CMAKE_OPTIONS+=" -DCMAKE_BUILD_TYPE=Release"
# compile and execute unit tests
- mkdir -p build && cd build
- cmake .. ${CMAKE_OPTIONS} -DJSON_BuildTests=On -GNinja && cmake --build .
- ctest --timeout 2700 -V -j
- cd ..
# check if homebrew works (only checks develop branch)
- if [ `which brew` ]; then
brew update ;
brew tap nlohmann/json ;
brew install nlohmann_json --HEAD ;
brew test nlohmann_json ;
fi
......@@ -7,8 +7,8 @@ authors:
email: mail@nlohmann.me
website: https://nlohmann.me
title: "JSON for Modern C++"
version: 3.10.4
date-released: 2021
version: 3.10.5
date-released: 2022
license: MIT
repository-code: "https://github.com/nlohmann"
url: https://json.nlohmann.me
......@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.1)
## PROJECT
## name and version
##
project(nlohmann_json VERSION 3.10.4 LANGUAGES CXX)
project(nlohmann_json VERSION 3.10.5 LANGUAGES CXX)
##
## MAIN_PROJECT CHECK
......
This diff is collapsed.
MIT License
Copyright (c) 2013-2021 Niels Lohmann
Copyright (c) 2013-2022 Niels Lohmann
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
This diff is collapsed.
......@@ -13,12 +13,12 @@ execute_process(COMMAND ${ASTYLE_TOOL} --version OUTPUT_VARIABLE ASTYLE_TOOL_VER
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" ASTYLE_TOOL_VERSION "${ASTYLE_TOOL_VERSION}")
message(STATUS "🔖 Artistic Style ${ASTYLE_TOOL_VERSION} (${ASTYLE_TOOL})")
find_program(CLANG_TOOL NAMES clang++-HEAD clang++-13 clang++-12 clang++-11 clang++)
find_program(CLANG_TOOL NAMES clang++-HEAD clang++-14 clang++-13 clang++-12 clang++-11 clang++)
execute_process(COMMAND ${CLANG_TOOL} --version OUTPUT_VARIABLE CLANG_TOOL_VERSION ERROR_VARIABLE CLANG_TOOL_VERSION)
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CLANG_TOOL_VERSION "${CLANG_TOOL_VERSION}")
message(STATUS "🔖 Clang ${CLANG_TOOL_VERSION} (${CLANG_TOOL})")
find_program(CLANG_TIDY_TOOL NAMES clang-tidy-12 clang-tidy-11 clang-tidy)
find_program(CLANG_TIDY_TOOL NAMES clang-tidy-14 clang-tidy-13 clang-tidy-12 clang-tidy-11 clang-tidy)
execute_process(COMMAND ${CLANG_TIDY_TOOL} --version OUTPUT_VARIABLE CLANG_TIDY_TOOL_VERSION ERROR_VARIABLE CLANG_TIDY_TOOL_VERSION)
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CLANG_TIDY_TOOL_VERSION "${CLANG_TIDY_TOOL_VERSION}")
message(STATUS "🔖 Clang-Tidy ${CLANG_TIDY_TOOL_VERSION} (${CLANG_TIDY_TOOL})")
......@@ -79,7 +79,7 @@ message(STATUS "🔖 Valgrind ${VALGRIND_TOOL_VERSION} (${VALGRIND_TOOL})")
find_program(GENHTML_TOOL NAMES genhtml)
find_program(PLOG_CONVERTER_TOOL NAMES plog-converter)
find_program(PVS_STUDIO_ANALYZER_TOOL NAMES pvs-studio-analyzer)
find_program(SCAN_BUILD_TOOL NAMES scan-build-12 scan-build-11 scan-build)
find_program(SCAN_BUILD_TOOL NAMES scan-build-14 scan-build-13 scan-build-12 scan-build-11 scan-build)
# the individual source files
file(GLOB_RECURSE SRC_FILES ${PROJECT_SOURCE_DIR}/include/nlohmann/*.hpp)
......@@ -811,14 +811,22 @@ add_custom_target(ci_cmake_flags
# Use more installed compilers.
###############################################################################
foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-7 g++-8 g++-9 g++-10 clang++-3.5 clang++-3.6 clang++-3.7 clang++-3.8 clang++-3.9 clang++-4.0 clang++-5.0 clang++-6.0 clang++-7 clang++-8 clang++-9 clang++-10 clang++-11 clang++-12)
foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-6 g++-7 g++-8 g++-9 g++-10 clang++-3.5 clang++-3.6 clang++-3.7 clang++-3.8 clang++-3.9 clang++-4.0 clang++-5.0 clang++-6.0 clang++-7 clang++-8 clang++-9 clang++-10 clang++-11 clang++-12 clang++-13)
find_program(COMPILER_TOOL NAMES ${COMPILER})
if (COMPILER_TOOL)
if ("${COMPILER}" STREQUAL "clang++-9")
# fix for https://github.com/nlohmann/json/pull/3101#issuecomment-998788786 / https://stackoverflow.com/a/64051725/266378
set(ADDITIONAL_FLAGS "-DCMAKE_CXX_FLAGS=--gcc-toolchain=/root/gcc/9")
else()
unset(ADDITIONAL_FLAGS)
endif()
add_custom_target(ci_test_compiler_${COMPILER}
COMMAND CXX=${COMPILER} ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
-DJSON_BuildTests=ON -DJSON_FastTests=ON
-S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_compiler_${COMPILER}
${ADDITIONAL_FLAGS}
COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_compiler_${COMPILER}
COMMAND cd ${PROJECT_BINARY_DIR}/build_compiler_${COMPILER} && ${CMAKE_CTEST_COMMAND} --parallel ${N} --exclude-regex "test-unicode" --output-on-failure
COMMENT "Compile and test with ${COMPILER}"
......@@ -827,6 +835,18 @@ foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-7 g++-8 g++-9 g++-10 clang++-3.5 clan
unset(COMPILER_TOOL CACHE)
endforeach()
###############################################################################
# CUDA example
###############################################################################
add_custom_target(ci_cuda_example
COMMAND ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja
-DCMAKE_CUDA_HOST_COMPILER=g++-8
-S${PROJECT_SOURCE_DIR}/test/cuda_example -B${PROJECT_BINARY_DIR}/build_cuda_example
COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_cuda_example
)
###############################################################################
# Clean up all generated files.
###############################################################################
......
This diff is collapsed.
SRCDIR = ../single_include
SED:=$(shell command -v gsed || which sed)
all: doxygen
all: create_output
##########################################################################
# example files
......@@ -24,49 +22,13 @@ EXAMPLES = $(wildcard examples/*.cpp)
diff $@ $(<:.cpp=.output)
rm $(<:.cpp=) $@
# create links to try the code online
%.link: %.cpp
rm -fr tmp
mkdir tmp
cp -r $(SRCDIR)/nlohmann tmp
python2 scripts/send_to_wandbox.py tmp $< > $@.tmp
/bin/echo -n "<a target=\"_blank\" href=\"`cat $@.tmp`\"><b>online</b></a>" > $@
rm -fr tmp $@.tmp
# create output from all stand-alone example files
create_output: $(EXAMPLES:.cpp=.output)
create_links: $(EXAMPLES:.cpp=.link)
# check output of all stand-alone example files
check_output: $(EXAMPLES:.cpp=.test)
clean:
rm -fr me.nlohmann.json.docset html $(EXAMPLES:.cpp=)
rm -fr $(EXAMPLES:.cpp=)
$(MAKE) clean -C docset
$(MAKE) clean -C mkdocs
##########################################################################
# Doxygen HTML documentation
##########################################################################
# create Doxygen documentation
doxygen: create_output create_links
doxygen
$(SED) -i 's@&lt; ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, AllocatorType, JSONSerializer &gt;@@g' html/*.html
$(SED) -i 's@&lt;&#160;ObjectType,&#160;ArrayType,&#160;StringType,&#160;BooleanType,&#160;NumberIntegerType,&#160;NumberFloatType,&#160;AllocatorType&#160;JSONSerializer&#160;&gt;@@g' html/*.html
$(SED) -i 's@&lt; ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer &gt;@@g' html/*.html
$(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >@@g' html/*.html
$(SED) -i 's@&lt;&#160;ObjectType,&#160;ArrayType,&#160;StringType,&#160;BooleanType,&#160;NumberIntegerType,&#160;NumberUnsignedType,&#160;NumberFloatType,&#160;AllocatorType&#160;JSONSerializer&#160;&gt;@@g' html/*.html
$(SED) -i 's@template&lt;template&lt; typename U, typename V, typename... Args &gt; class ObjectType = std::map, template&lt; typename U, typename... Args &gt; class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template&lt; typename U &gt; class AllocatorType = std::allocator, template&lt; typename T, typename SFINAE=void &gt; class JSONSerializer = adl_serializer&gt;@@g' html/*.html
$(SED) -i 's@&lt; ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer &gt;@@g' html/*.html
$(SED) -i 's@&lt;&#160;ObjectType,&#160;ArrayType,&#160;StringType,&#160;BooleanType,&#160;NumberIntegerType,&#160;NumberUnsignedType,&#160;NumberFloatType,&#160;AllocatorType,&#160;JSONSerializer&#160;&gt;@@g' html/*.html
$(SED) -i 's@JSON_HEDLEY_RETURNS_NON_NULL@@g' html/*.html
$(SED) -i 's@JSON_HEDLEY_WARN_UNUSED_RESULT@@g' html/*.html
upload: clean doxygen check_output
scripts/git-update-ghpages nlohmann/json html
rm -fr html
open http://nlohmann.github.io/json/
# Documentation
## Generate documentation
Note on documentation: The source files contain links to the online documentation at https://json.nlohmann.me. This URL
contains the most recent documentation and should also be applicable to previous versions; documentation for deprecated
functions is not removed, but marked deprecated.
If you want to see the documentation for a specific tag or commit hash, you can generate it as follows (here for tag
`v3.10.2`):
```shell
git clone https://github.com/nlohmann/json.git
cd json
git checkout v3.10.2
make install_venv serve -C doc/mkdocs
```
Open URL <http://127.0.0.1:8000/> in your browser. Replace from any URL from the source code `https://json.nlohmann.me`
with `http://127.0.0.1:8000` to see the documentation for your tag or commit hash.
doc/avatars.png

1.31 MB | W: | H:

doc/avatars.png

1.34 MB | W: | H:

doc/avatars.png
doc/avatars.png
doc/avatars.png
doc/avatars.png
  • 2-up
  • Swipe
  • Onion skin
/* hide lengthy template information */
.memtemplate, .memTemplParams {
display: none;
}
/* allow compiler information to wrap */
/* https://css-tricks.com/snippets/css/make-pre-text-wrap/ */
pre.fragment {
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
td.paramname {
vertical-align: top;
}
.ok_green {
background-color: #89C35C;
}
.nok_throws {
background-color: #ffa500;
}
.memtemplate {
display: none;
}
.memTemplParams {
display: none;
}
.navtab {
display: none;
}
#top, .footer {
display: none;
}
td.paramname {
vertical-align: top;
}
.ok_green {
background-color: #89C35C;
}
.nok_throws {
background-color: #ffa500;
}
<a target="_blank" href="https://wandbox.org/permlink/1mp10JbaANo6FUc7"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/r5Tai1spihWHTdFA"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/Ptk2BoNyGfrZfxRU"><b>online</b></a>
\ No newline at end of file
#include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
std::cout << std::boolalpha << std::is_same<std::vector<json>, json::array_t>::value << std::endl;
}
<a target="_blank" href="https://wandbox.org/permlink/055DW3OWJPwGYr92"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/gM1uqvzukokLwjMa"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/H3tBOr4lpufGRHlF"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/UtGhIQGxCYIml36F"><b>online</b></a>
\ No newline at end of file
......@@ -60,7 +60,7 @@ int main()
// out_of_range.401
try
{
// try to use a an invalid array index
// try to use an invalid array index
json::reference ref = j.at("/array/4"_json_pointer);
}
catch (json::out_of_range& e)
......@@ -82,7 +82,7 @@ int main()
// out_of_range.403
try
{
// try to use a JSON pointer to an nonexistent object key
// try to use a JSON pointer to a nonexistent object key
json::const_reference ref = j.at("/foo"_json_pointer);
}
catch (json::out_of_range& e)
......
<a target="_blank" href="https://wandbox.org/permlink/NHe5FLR1KYaiHwBx"><b>online</b></a>
\ No newline at end of file
......@@ -36,7 +36,7 @@ int main()
// out_of_range.401
try
{
// try to use a an invalid array index
// try to use an invalid array index
json::const_reference ref = j.at("/array/4"_json_pointer);
}
catch (json::out_of_range& e)
......@@ -58,7 +58,7 @@ int main()
// out_of_range.403
try
{
// try to use a JSON pointer to an nonexistent object key
// try to use a JSON pointer to a nonexistent object key
json::const_reference ref = j.at("/foo"_json_pointer);
}
catch (json::out_of_range& e)
......
<a target="_blank" href="https://wandbox.org/permlink/lbZjdwg6yII33cV5"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/swnzqmd8zj6ij1fb"><b>online</b></a>
\ No newline at end of file
......@@ -81,7 +81,7 @@ int main()
json j_list(c_list);
// create an array from std::forward_list
std::forward_list<int64_t> c_flist {12345678909876, 23456789098765, 34567890987654, 45678909876543};
std::forward_list<std::int64_t> c_flist {12345678909876, 23456789098765, 34567890987654, 45678909876543};
json j_flist(c_flist);
// create an array from std::array
......
<a target="_blank" href="https://wandbox.org/permlink/RodBcX8vpcP5dQ40"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/oWFo4AhVlMBjNv8E"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/oRn0YsYyurs0Zi5T"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/kVknQzPMpqjywTpG"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/yzkjGGzMOESBkCdH"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/eIOvQiuID2qgxp5u"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/Vm0nR32x6co8rq40"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/w4TtEQzlVyokIrtp"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/mNy1nyabOkeHfHGf"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/a3H6kpORXgbVXylv"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/yXZGDwDHH3LOuFIr"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/fS4kfQG1hmhjMScn"><b>online</b></a>
\ No newline at end of file
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create a binary vector
std::vector<std::uint8_t> vec = {0xCA, 0xFE, 0xBA, 0xBE};
// create a binary JSON value with subtype 42
json j = json::binary(vec, 42);
// output type and subtype
std::cout << "type: " << j.type_name() << ", subtype: " << j.get_binary().subtype() << std::endl;
}
type: binary, subtype: 42
#include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
std::cout << std::boolalpha << std::is_same<nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>, json::binary_t>::value << std::endl;
}
#include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
std::cout << std::boolalpha << std::is_same<bool, json::boolean_t>::value << std::endl;
}
<a target="_blank" href="https://wandbox.org/permlink/hxcSxCPPLHpZMxjS"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/xbnldrrN05tKIOEv"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/gDQPYFxMrvD7RK4z"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/vVY4F4xKC3v6pG6F"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/Q2GTzxF8NA10kVvD"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/6LRjg1bqwchPUoDx"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/JMDd9jiP0flRKJ6C"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/HdlqwPk8bDfrZ4AE"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/pbz3ULoJ4maRnV8N"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/fWfQhHzG03P6PAcC"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/GHVHgDpT5vx0KMPD"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/DyMiKrkKMwd3R7OU"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/p9P3Ph8mdxMON6SY"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/yMxKrJfRedlFygJD"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/zaexgkNdH3HYJm8D"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/eQ0YI8wWcMIHtBCS"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/SD62jUgeIuudweZu"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/gG3bN97HOF04Xw6S"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/WSnobkZJZHUPUIRF"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/GGoqGtqEzxAsAKnI"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/vky6QCTCqtUnNVlD"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/aQjZSjuuDUxXQCjJ"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/moO4IdryeGS8QmKo"><b>online</b></a>
\ No newline at end of file
......@@ -7,11 +7,11 @@ using json = nlohmann::json;
int main()
{
// create byte vector
std::vector<uint8_t> v = {0x1b, 0x00, 0x00, 0x00, 0x08, 0x63, 0x6f, 0x6d,
0x70, 0x61, 0x63, 0x74, 0x00, 0x01, 0x10, 0x73,
0x63, 0x68, 0x65, 0x6d, 0x61, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00
};
std::vector<std::uint8_t> v = {0x1b, 0x00, 0x00, 0x00, 0x08, 0x63, 0x6f, 0x6d,
0x70, 0x61, 0x63, 0x74, 0x00, 0x01, 0x10, 0x73,
0x63, 0x68, 0x65, 0x6d, 0x61, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00
};
// deserialize it with BSON
json j = json::from_bson(v);
......
<a target="_blank" href="https://wandbox.org/permlink/Q7O1liz5QrgQynqQ"><b>online</b></a>
\ No newline at end of file
......@@ -7,10 +7,10 @@ using json = nlohmann::json;
int main()
{
// create byte vector
std::vector<uint8_t> v = {0xa2, 0x67, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63,
0x74, 0xf5, 0x66, 0x73, 0x63, 0x68, 0x65, 0x6d,
0x61, 0x00
};
std::vector<std::uint8_t> v = {0xa2, 0x67, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63,
0x74, 0xf5, 0x66, 0x73, 0x63, 0x68, 0x65, 0x6d,
0x61, 0x00
};
// deserialize it with CBOR
json j = json::from_cbor(v);
......
<a target="_blank" href="https://wandbox.org/permlink/AjdbchxfTsN9PHCL"><b>online</b></a>
\ No newline at end of file
......@@ -7,10 +7,10 @@ using json = nlohmann::json;
int main()
{
// create byte vector
std::vector<uint8_t> v = {0x82, 0xa7, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63,
0x74, 0xc3, 0xa6, 0x73, 0x63, 0x68, 0x65, 0x6d,
0x61, 0x00
};
std::vector<std::uint8_t> v = {0x82, 0xa7, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63,
0x74, 0xc3, 0xa6, 0x73, 0x63, 0x68, 0x65, 0x6d,
0x61, 0x00
};
// deserialize it with MessagePack
json j = json::from_msgpack(v);
......
<a target="_blank" href="https://wandbox.org/permlink/TdJfkKx0RAH5NB62"><b>online</b></a>
\ No newline at end of file
......@@ -7,10 +7,10 @@ using json = nlohmann::json;
int main()
{
// create byte vector
std::vector<uint8_t> v = {0x7B, 0x69, 0x07, 0x63, 0x6F, 0x6D, 0x70, 0x61,
0x63, 0x74, 0x54, 0x69, 0x06, 0x73, 0x63, 0x68,
0x65, 0x6D, 0x61, 0x69, 0x00, 0x7D
};
std::vector<std::uint8_t> v = {0x7B, 0x69, 0x07, 0x63, 0x6F, 0x6D, 0x70, 0x61,
0x63, 0x74, 0x54, 0x69, 0x06, 0x73, 0x63, 0x68,
0x65, 0x6D, 0x61, 0x69, 0x00, 0x7D
};
// deserialize it with UBJSON
json j = json::from_ubjson(v);
......
<a target="_blank" href="https://wandbox.org/permlink/GG9VzOZh1MDeTSsK"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/LtqaiI6oRplSg0KI"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/ddVSXnbULrNrCbRs"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/QjVgxx0bwbKuE9HI"><b>online</b></a>
\ No newline at end of file
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create a binary vector
std::vector<std::uint8_t> vec = {0xCA, 0xFE, 0xBA, 0xBE};
// create a binary JSON value with subtype 42
json j = json::binary(vec, 42);
// output type and subtype
std::cout << "type: " << j.type_name() << ", subtype: " << j.get_binary().subtype() << std::endl;
}
type: binary, subtype: 42
<a target="_blank" href="https://wandbox.org/permlink/eA1KrytMlQl1SURe"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/jVaWWe3kAjKKn99V"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/UvdMlXdPnXFUq1lJ"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/N1nlz2liDCmBn40h"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/eoHfSYf04soRkOto"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/oNhgDq5ejDl5RyqW"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/LdmbgtdndQw81wQU"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/kp99ButEWpuNxPbq"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/oUdIj3ZSbg7UCIuz"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/2ZgSEJ7UBJ9d4H6b"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/to5RDM1vhrDMUfVv"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/20OXaCBWTM1dhFmv"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/rTNvfIpTXdFXIe20"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/GCQOJn7fTbm6kPBo"><b>online</b></a>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment