mirror of
https://github.com/nlohmann/json.git
synced 2026-02-17 17:14:00 +00:00
Compare commits
406 Commits
v3.8.0
...
feature/op
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ffd3ae400 | ||
|
|
384442e8e5 | ||
|
|
f1913fe7a9 | ||
|
|
68c3696382 | ||
|
|
1587acdb1d | ||
|
|
be32cd0196 | ||
|
|
00e3f69a26 | ||
|
|
581f92b601 | ||
|
|
ebb63bd1fa | ||
|
|
a8398a7151 | ||
|
|
fc7e181cbf | ||
|
|
bdb2469c31 | ||
|
|
c886646707 | ||
|
|
4402176df5 | ||
|
|
e4fc598466 | ||
|
|
77be4f6aaf | ||
|
|
91d7aa571f | ||
|
|
ca51dc62f2 | ||
|
|
433da31334 | ||
|
|
7b98df515f | ||
|
|
98b2152452 | ||
|
|
ff3863dc1d | ||
|
|
467f622c65 | ||
|
|
5dd06714b1 | ||
|
|
dfedefb993 | ||
|
|
f15d447522 | ||
|
|
5e55158d60 | ||
|
|
f78d456075 | ||
|
|
9493f4beb1 | ||
|
|
cd7acc1dc5 | ||
|
|
39b8d6bd33 | ||
|
|
aae0e4959e | ||
|
|
8247a217bb | ||
|
|
c3c574cf96 | ||
|
|
a1772743a1 | ||
|
|
8593260044 | ||
|
|
c026e1a475 | ||
|
|
af8c6e7aa9 | ||
|
|
5c1a5bc9c1 | ||
|
|
45810082d4 | ||
|
|
5cc5285fe8 | ||
|
|
94d177e09a | ||
|
|
467986fe98 | ||
|
|
2fc1f694ad | ||
|
|
1771e9249f | ||
|
|
85ffc85a29 | ||
|
|
ea759d0360 | ||
|
|
97fe455ad5 | ||
|
|
d028eff9e1 | ||
|
|
be32cc4f5e | ||
|
|
47c2004f7f | ||
|
|
fc4040ce9d | ||
|
|
6390fca71a | ||
|
|
260be043ba | ||
|
|
5026acd70c | ||
|
|
30dd0c0f09 | ||
|
|
3ad6992f50 | ||
|
|
e3643aadf7 | ||
|
|
d9e2b191ad | ||
|
|
790508887e | ||
|
|
5c589dd138 | ||
|
|
972c15f26e | ||
|
|
5155cc2c48 | ||
|
|
d8d8cbf6e0 | ||
|
|
3322c9df6e | ||
|
|
cde29b3a11 | ||
|
|
eaac918034 | ||
|
|
9f45d314d5 | ||
|
|
64ff1cf90d | ||
|
|
71cb7d12da | ||
|
|
42a9dc0bc3 | ||
|
|
b273f28dae | ||
|
|
fd7a9f6007 | ||
|
|
1bcabd9e83 | ||
|
|
1047d09b2a | ||
|
|
d9843fc9fc | ||
|
|
6030a11051 | ||
|
|
14f8be11ce | ||
|
|
b9d76516a2 | ||
|
|
9d81eedb42 | ||
|
|
b386f4de0b | ||
|
|
3be6ee3525 | ||
|
|
fe507a7ee8 | ||
|
|
6b04f05eba | ||
|
|
5c4cc20ed8 | ||
|
|
a430d25f22 | ||
|
|
fb5c20134f | ||
|
|
d8ed98a7af | ||
|
|
1ce0ed5a52 | ||
|
|
0c2088823d | ||
|
|
fb8adb8e93 | ||
|
|
f6c2947f1e | ||
|
|
0356e0c75b | ||
|
|
6674561d6a | ||
|
|
772f37c12d | ||
|
|
67d822d951 | ||
|
|
298420263b | ||
|
|
dd2fb3b454 | ||
|
|
ce6adc447a | ||
|
|
d360fec216 | ||
|
|
178125ff9b | ||
|
|
8d0aa09ab5 | ||
|
|
874f49e945 | ||
|
|
fe89049aee | ||
|
|
9d726c25d5 | ||
|
|
411fc3249b | ||
|
|
b888afe5f4 | ||
|
|
37ce871eeb | ||
|
|
dd8cb2acc1 | ||
|
|
4080d0b1a4 | ||
|
|
1b28a58280 | ||
|
|
824d55bf26 | ||
|
|
e030d26089 | ||
|
|
41a99567e0 | ||
|
|
fedf82c904 | ||
|
|
db78ac1d77 | ||
|
|
b3e5cb7f20 | ||
|
|
f4155e4727 | ||
|
|
8a54617240 | ||
|
|
0326e4e2a6 | ||
|
|
3888b1642a | ||
|
|
1da931730a | ||
|
|
1eedee5e4e | ||
|
|
501ad6fc59 | ||
|
|
35daa5c00b | ||
|
|
2326abc547 | ||
|
|
f13af83a94 | ||
|
|
2d3fe9d135 | ||
|
|
e590604822 | ||
|
|
1b8efed06f | ||
|
|
7d01a9e875 | ||
|
|
b3da8b325a | ||
|
|
aa06a4761e | ||
|
|
8f9dc7eabe | ||
|
|
d34771cafc | ||
|
|
e110667d21 | ||
|
|
c006fc9bec | ||
|
|
84c0c76849 | ||
|
|
2f05f5175c | ||
|
|
1b06184f22 | ||
|
|
84a899f511 | ||
|
|
7a4841a42a | ||
|
|
bbcdf18ba5 | ||
|
|
e22cbacc41 | ||
|
|
67ed63b196 | ||
|
|
a34070d36a | ||
|
|
9c75c7eace | ||
|
|
7bd6242f04 | ||
|
|
808aca41aa | ||
|
|
63e7c40e35 | ||
|
|
1816aae862 | ||
|
|
980f8c6f61 | ||
|
|
42f8708940 | ||
|
|
40b78d3847 | ||
|
|
fad14aabe7 | ||
|
|
6e5be17b62 | ||
|
|
62f98b7537 | ||
|
|
a1dbfcd736 | ||
|
|
c00c3162b2 | ||
|
|
448ceb2e12 | ||
|
|
15ec0fe150 | ||
|
|
58167173a2 | ||
|
|
d8d499ce9b | ||
|
|
480ad529e3 | ||
|
|
a84370c61f | ||
|
|
33662417c1 | ||
|
|
0f22ed0b5b | ||
|
|
12885446d8 | ||
|
|
3c7dc635e7 | ||
|
|
27232455c8 | ||
|
|
59cb7674be | ||
|
|
0cd120f7e1 | ||
|
|
bba57cc4af | ||
|
|
e571c67c0d | ||
|
|
43e07bb92d | ||
|
|
fb22233f34 | ||
|
|
f9b71afebf | ||
|
|
8159091d8f | ||
|
|
230dcfb7a3 | ||
|
|
b315fe484a | ||
|
|
a33c3fdf25 | ||
|
|
88122467bd | ||
|
|
a048b72fe1 | ||
|
|
484029b51c | ||
|
|
a6d112ffbf | ||
|
|
2301bd1177 | ||
|
|
c4356c68e0 | ||
|
|
4d63252c6c | ||
|
|
a7c4c84d68 | ||
|
|
797329315a | ||
|
|
74b446f5fd | ||
|
|
2cd10a7405 | ||
|
|
6bd38a2cb9 | ||
|
|
8b14c9b305 | ||
|
|
3bb43ecd51 | ||
|
|
3249a4d821 | ||
|
|
96e9f66025 | ||
|
|
8046754c15 | ||
|
|
b1903fff1f | ||
|
|
1339d6b683 | ||
|
|
a9117828e1 | ||
|
|
8344857764 | ||
|
|
4a5277d09d | ||
|
|
8aa6da61dc | ||
|
|
7360e09830 | ||
|
|
35b899e988 | ||
|
|
7cf2fe149c | ||
|
|
7660ea12f6 | ||
|
|
893eda8353 | ||
|
|
678d310b85 | ||
|
|
e83ddb185d | ||
|
|
254f0e3cee | ||
|
|
578217eaa3 | ||
|
|
6d9b2040ab | ||
|
|
75a6888d55 | ||
|
|
8f14aaa13f | ||
|
|
851315c878 | ||
|
|
f7374c9a8d | ||
|
|
0a158ee830 | ||
|
|
21bd6e971b | ||
|
|
0b744e1ed0 | ||
|
|
8a045713ed | ||
|
|
a575008c48 | ||
|
|
5eb739a585 | ||
|
|
68122fe0ed | ||
|
|
b1da58b76b | ||
|
|
1fd6c5882a | ||
|
|
d371a5283c | ||
|
|
ab25de05f7 | ||
|
|
a3a9d5665e | ||
|
|
0d2d088b97 | ||
|
|
c122d8a94f | ||
|
|
4706d6e976 | ||
|
|
9afe757648 | ||
|
|
8730af0788 | ||
|
|
beb1fb48f0 | ||
|
|
88243b3f8c | ||
|
|
281349d0d6 | ||
|
|
43ab8a2357 | ||
|
|
7fc4b2901a | ||
|
|
2fd57d3ed1 | ||
|
|
a10d486e36 | ||
|
|
e65cc9dccb | ||
|
|
548e7e54c9 | ||
|
|
6023a7ccd9 | ||
|
|
270f1ae482 | ||
|
|
d047b3d495 | ||
|
|
26196f25f6 | ||
|
|
3d60befde3 | ||
|
|
7f6ea47bdb | ||
|
|
4c59d6aaef | ||
|
|
23c97f4aa5 | ||
|
|
93cdf05928 | ||
|
|
01e196f6b6 | ||
|
|
b821ed074f | ||
|
|
496ddd127c | ||
|
|
9449dfcc6a | ||
|
|
25a59b59f2 | ||
|
|
6d7f8b3793 | ||
|
|
33b0bed7fe | ||
|
|
5b229f4cce | ||
|
|
1a521cbd36 | ||
|
|
8921e5e5db | ||
|
|
88adffdaba | ||
|
|
938b867450 | ||
|
|
3952739189 | ||
|
|
a244531627 | ||
|
|
cf741313b3 | ||
|
|
e316f5c5b6 | ||
|
|
486812904f | ||
|
|
4d28694756 | ||
|
|
738c83d6af | ||
|
|
8d295235a5 | ||
|
|
6477b9b20a | ||
|
|
7f923424b3 | ||
|
|
dc06f100be | ||
|
|
889f269a6c | ||
|
|
b2240f7508 | ||
|
|
609a0046c4 | ||
|
|
3a80823ff8 | ||
|
|
9c21285133 | ||
|
|
5f146cb853 | ||
|
|
47d154dd49 | ||
|
|
f9a1fec272 | ||
|
|
cbafed3494 | ||
|
|
f62b4626be | ||
|
|
0eb7b0a991 | ||
|
|
75d5d05993 | ||
|
|
4c7bd014d9 | ||
|
|
d740622f96 | ||
|
|
251fce819c | ||
|
|
c7d18c1625 | ||
|
|
0306525cdb | ||
|
|
f774a32d2b | ||
|
|
e3e9ccfc02 | ||
|
|
1b04092c5c | ||
|
|
d019ddfcdb | ||
|
|
dd08f7705f | ||
|
|
28ef87370b | ||
|
|
99fc6b16ab | ||
|
|
ba8174041e | ||
|
|
efcc826ecb | ||
|
|
98b1c6d302 | ||
|
|
b04dc055b2 | ||
|
|
197c3d4fb0 | ||
|
|
803c16e5af | ||
|
|
25f5d75e6e | ||
|
|
93770467a1 | ||
|
|
0fc261f0f2 | ||
|
|
e54f03f73b | ||
|
|
f59f4a2b61 | ||
|
|
c7e079cc98 | ||
|
|
ad6eadeb70 | ||
|
|
49f26a0250 | ||
|
|
eb7376bb13 | ||
|
|
470f7c0c68 | ||
|
|
1b4ea8f89b | ||
|
|
d7a2956b24 | ||
|
|
ac3922c7aa | ||
|
|
fa9f4040df | ||
|
|
5ba0f65c34 | ||
|
|
aefa0b3e86 | ||
|
|
3948b5b091 | ||
|
|
1af4f5f360 | ||
|
|
c5ee222982 | ||
|
|
ec43371e07 | ||
|
|
635b9a0ae4 | ||
|
|
cf18ba2394 | ||
|
|
08963d6826 | ||
|
|
d08fca2bb9 | ||
|
|
5e7bdf1cab | ||
|
|
fb8c11f25c | ||
|
|
acd748e16f | ||
|
|
49623a75ee | ||
|
|
8575fdf9ad | ||
|
|
4bfe4add20 | ||
|
|
0ecf297457 | ||
|
|
a9809f3381 | ||
|
|
8b3d2399a4 | ||
|
|
5fe3d3929a | ||
|
|
064a9c9212 | ||
|
|
ddf0a45abb | ||
|
|
aeef50709e | ||
|
|
ecbb2756fd | ||
|
|
65e8ee985a | ||
|
|
15337b2cc3 | ||
|
|
27aaf6f845 | ||
|
|
29ad2178c6 | ||
|
|
e22ce45065 | ||
|
|
139a0258cc | ||
|
|
8dade80499 | ||
|
|
f0e73163f2 | ||
|
|
0fe9f23254 | ||
|
|
6ee9e5f402 | ||
|
|
24992003d9 | ||
|
|
e4675887a6 | ||
|
|
74c6e4295f | ||
|
|
4fd0d02b6f | ||
|
|
b64002bbca | ||
|
|
0585ecc56b | ||
|
|
cd115cbc33 | ||
|
|
74520d8bb0 | ||
|
|
88a37010d6 | ||
|
|
e9bfcf7255 | ||
|
|
4a6c68c7eb | ||
|
|
da8fa3535a | ||
|
|
e86b3fae98 | ||
|
|
f466919ec2 | ||
|
|
8aaa4013a3 | ||
|
|
4d96f4cf6a | ||
|
|
f4c4bab600 | ||
|
|
b53c6e2f81 | ||
|
|
691fb0c57a | ||
|
|
a3df26b771 | ||
|
|
71830be06d | ||
|
|
82fbbeeac5 | ||
|
|
225c8f150a | ||
|
|
24e8562664 | ||
|
|
a53e3a5443 | ||
|
|
dc323314d5 | ||
|
|
402c34c526 | ||
|
|
65c4b07451 | ||
|
|
0498202a03 | ||
|
|
4f04ea1bef | ||
|
|
5ea205f570 | ||
|
|
5f10d5d156 | ||
|
|
7c0c522b96 | ||
|
|
522ec5d7bd | ||
|
|
7e5c2a480a | ||
|
|
9c971c2d2f | ||
|
|
4ba8c95794 | ||
|
|
fbd3e8f677 | ||
|
|
0309025b45 | ||
|
|
9191926fff | ||
|
|
42ef2a5adb | ||
|
|
2182935397 | ||
|
|
b61d563ebe | ||
|
|
f25bf312fc | ||
|
|
007c6c4bc5 | ||
|
|
71c80ccfd8 | ||
|
|
6b31375c7c | ||
|
|
a2fea87ef6 | ||
|
|
1b846c9d81 | ||
|
|
713038fa27 | ||
|
|
1359c56137 | ||
|
|
df30a0ea07 |
@@ -44,5 +44,13 @@ workflows:
|
||||
version: 2
|
||||
build_and_test_all:
|
||||
jobs:
|
||||
- build_stable
|
||||
- build_bleeding_edge
|
||||
- build_stable:
|
||||
filters:
|
||||
branches:
|
||||
ignore:
|
||||
gh-pages
|
||||
- build_bleeding_edge:
|
||||
filters:
|
||||
branches:
|
||||
ignore:
|
||||
gh-pages
|
||||
|
||||
84
.clang-format
Normal file
84
.clang-format
Normal file
@@ -0,0 +1,84 @@
|
||||
#AccessModifierOffset: 2
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: false
|
||||
#AlignConsecutiveBitFields: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignConsecutiveMacros: false
|
||||
AlignEscapedNewlines: Right
|
||||
#AlignOperands: AlignAfterOperator
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: Empty
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
#AllowShortEnumsOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: Empty
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: Empty
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
#BitFieldColonSpacing: Both
|
||||
BreakBeforeBraces: Custom # or Allman
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: true
|
||||
AfterClass: true
|
||||
AfterControlStatement: Always
|
||||
AfterEnum: true
|
||||
AfterFunction: true
|
||||
AfterNamespace: false
|
||||
AfterStruct: true
|
||||
AfterUnion: true
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: true
|
||||
BeforeElse: true
|
||||
#BeforeLambdaBody: false
|
||||
#BeforeWhile: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: false
|
||||
SplitEmptyNamespace: false
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializers: BeforeComma
|
||||
BreakStringLiterals: false
|
||||
ColumnLimit: 0
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerIndentWidth: 2
|
||||
Cpp11BracedListStyle: true
|
||||
PointerAlignment: Left
|
||||
FixNamespaceComments: true
|
||||
IncludeBlocks: Preserve
|
||||
#IndentCaseBlocks: false
|
||||
IndentCaseLabels: true
|
||||
IndentGotoLabels: false
|
||||
IndentPPDirectives: BeforeHash
|
||||
IndentWidth: 4
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ReflowComments: false
|
||||
SortIncludes: true
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceBeforeSquareBrackets: false
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 2
|
||||
SpacesInAngles: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: c++11
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
27
.clang-tidy
27
.clang-tidy
@@ -1,23 +1,20 @@
|
||||
Checks: '-*,
|
||||
bugprone-*,
|
||||
cert-*,
|
||||
clang-analyzer-*,
|
||||
google-*,
|
||||
-google-runtime-references,
|
||||
Checks: '*,
|
||||
-cppcoreguidelines-avoid-goto,
|
||||
-cppcoreguidelines-avoid-magic-numbers,
|
||||
-cppcoreguidelines-macro-usage,
|
||||
-fuchsia-default-arguments-calls,
|
||||
-fuchsia-default-arguments-declarations,
|
||||
-fuchsia-overloaded-operator,
|
||||
-google-explicit-constructor,
|
||||
hicpp-*,
|
||||
-google-runtime-references,
|
||||
-hicpp-avoid-goto,
|
||||
-hicpp-explicit-conversions,
|
||||
-hicpp-no-array-decay,
|
||||
-hicpp-uppercase-literal-suffix,
|
||||
-hicpp-explicit-conversions,
|
||||
misc-*,
|
||||
-misc-non-private-member-variables-in-classes,
|
||||
llvm-*,
|
||||
-llvm-header-guard,
|
||||
modernize-*,
|
||||
-llvm-include-order,
|
||||
-misc-non-private-member-variables-in-classes,
|
||||
-modernize-use-trailing-return-type,
|
||||
performance-*,
|
||||
portability-*,
|
||||
readability-*,
|
||||
-readability-magic-numbers,
|
||||
-readability-uppercase-literal-suffix'
|
||||
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/Bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/Bug_report.md
vendored
@@ -47,7 +47,7 @@ assignees: ''
|
||||
|
||||
<!-- Please add an `x` to the respective line. -->
|
||||
|
||||
- [ ] latest release version 3.7.3
|
||||
- [ ] latest release version 3.9.1
|
||||
- [ ] other release - please state the version: ___
|
||||
- [ ] the `develop` branch
|
||||
|
||||
|
||||
16
.github/ISSUE_TEMPLATE/Feature_request.md
vendored
16
.github/ISSUE_TEMPLATE/Feature_request.md
vendored
@@ -1,16 +0,0 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: 'kind: enhancement/improvement'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
#### Which feature do you want to see in the library?
|
||||
|
||||
<!-- Describe the feature in as much detail as possible. -->
|
||||
|
||||
#### How would the feature be usable for other users?
|
||||
|
||||
<!-- Include sample usage where appropriate. -->
|
||||
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Ask a question
|
||||
url: https://github.com/nlohmann/json/discussions
|
||||
about: Ask questions and discuss with other community members
|
||||
40
.github/ISSUE_TEMPLATE/question.md
vendored
40
.github/ISSUE_TEMPLATE/question.md
vendored
@@ -1,40 +0,0 @@
|
||||
---
|
||||
name: Question
|
||||
about: Ask a question regarding the library.
|
||||
title: ''
|
||||
labels: 'kind: question'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- Provide a concise summary of the issue in the title above. -->
|
||||
|
||||
#### What do you want to achieve?
|
||||
|
||||
<!-- Please describe the feature as detailed as possible. -->
|
||||
|
||||
#### What have you tried?
|
||||
|
||||
<!-- There are thousands of issues to search: https://github.com/nlohmann/json/issues?q=is%3Aissue+ -->
|
||||
<!-- There is a full documentation of the API: https://nlohmann.github.io/json/ -->
|
||||
<!-- There is a detailed README file: https://github.com/nlohmann/json/blob/develop/README.md -->
|
||||
|
||||
#### Can you provide a small code example?
|
||||
|
||||
<!-- Please understand that we cannot analyze and debug large code bases. -->
|
||||
|
||||
#### Which compiler and operating system are you using?
|
||||
|
||||
<!-- Include as many relevant details about the environment you experienced the bug in. -->
|
||||
<!-- Make sure you use a supported compiler, see https://github.com/nlohmann/json#supported-compilers. -->
|
||||
|
||||
- Compiler: ___
|
||||
- Operating system: ___
|
||||
|
||||
#### Which version of the library did you use?
|
||||
|
||||
<!-- Please add an `x` to the respective line. -->
|
||||
|
||||
- [ ] latest release version 3.7.3
|
||||
- [ ] other release - please state the version: ___
|
||||
- [ ] the `develop` branch
|
||||
54
.github/workflows/codeql-analysis.yml
vendored
Normal file
54
.github/workflows/codeql-analysis.yml
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
name: "Code scanning - action"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [develop, ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [develop]
|
||||
schedule:
|
||||
- cron: '0 19 * * 1'
|
||||
|
||||
jobs:
|
||||
CodeQL-Build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# We must fetch at least the immediate parents so that if this is
|
||||
# a pull request then we can checkout the head.
|
||||
fetch-depth: 2
|
||||
|
||||
# If this run was triggered by a pull request event, then checkout
|
||||
# the head of the pull request instead of the merge commit.
|
||||
- run: git checkout HEAD^2
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
# Override language selection by uncommenting this and choosing your languages
|
||||
# with:
|
||||
# languages: go, javascript, csharp, python, cpp, java
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
51
.github/workflows/ubuntu.yml
vendored
51
.github/workflows/ubuntu.yml
vendored
@@ -3,14 +3,61 @@ name: Ubuntu
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
gcc_build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: install_gcc
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install gcc-10 g++-10
|
||||
shell: bash
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
|
||||
env:
|
||||
CC: gcc-10
|
||||
CXX: g++-10
|
||||
- name: build
|
||||
run: cmake --build build --parallel 10
|
||||
- name: test
|
||||
run: cd build ; ctest -j 10 --output-on-failure
|
||||
|
||||
clang_build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: install_gcc
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install clang-10
|
||||
shell: bash
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
|
||||
env:
|
||||
CC: clang-10
|
||||
CXX: clang++-10
|
||||
- name: build
|
||||
run: cmake --build build --parallel 10
|
||||
- name: test
|
||||
run: cd build ; ctest -j 10 --output-on-failure
|
||||
|
||||
clang_build_cxx20:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: install_gcc
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install clang-10
|
||||
shell: bash
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=ON
|
||||
env:
|
||||
CC: clang-10
|
||||
CXX: clang++-10
|
||||
- name: build
|
||||
run: cmake --build build --parallel 10
|
||||
- name: test
|
||||
|
||||
41
.github/workflows/windows.yml
vendored
41
.github/workflows/windows.yml
vendored
@@ -3,8 +3,7 @@ name: Windows
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
msvc2019:
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
@@ -15,3 +14,41 @@ jobs:
|
||||
run: cmake --build build --parallel 10
|
||||
- name: test
|
||||
run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure
|
||||
|
||||
clang10:
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: install Clang
|
||||
run: curl -fsSL -o LLVM10.exe https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/LLVM-10.0.0-win64.exe ; 7z x LLVM10.exe -y -o"C:/Program Files/LLVM"
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang++.exe" -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
|
||||
- name: build
|
||||
run: cmake --build build --parallel 10
|
||||
- name: test
|
||||
run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure
|
||||
|
||||
clang-cl-10-x64:
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -G "Visual Studio 16 2019" -A x64 -T ClangCL -DJSON_BuildTests=On
|
||||
- name: build
|
||||
run: cmake --build build --config Debug --parallel 10
|
||||
- name: test
|
||||
run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure
|
||||
|
||||
clang-cl-10-x86:
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: cmake
|
||||
run: cmake -S . -B build -G "Visual Studio 16 2019" -A Win32 -T ClangCL -DJSON_BuildTests=On
|
||||
- name: build
|
||||
run: cmake --build build --config Debug --parallel 10
|
||||
- name: test
|
||||
run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -22,7 +22,7 @@ benchmarks/files/numbers/*.json
|
||||
.wsjcpp/*
|
||||
|
||||
.idea
|
||||
cmake-build-debug
|
||||
/cmake-build-*
|
||||
|
||||
test/test-*
|
||||
/.vs
|
||||
@@ -32,3 +32,5 @@ doc/mkdocs/docs/images
|
||||
doc/mkdocs/docs/examples
|
||||
doc/mkdocs/site
|
||||
doc/mkdocs/docs/__pycache__/
|
||||
doc/xml
|
||||
/doc/docset/nlohmann_json.docset/
|
||||
|
||||
57
.travis.yml
57
.travis.yml
@@ -10,17 +10,6 @@ sudo: required
|
||||
group: edge
|
||||
|
||||
|
||||
###################
|
||||
# global settings #
|
||||
###################
|
||||
|
||||
env:
|
||||
global:
|
||||
# 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="
|
||||
|
||||
|
||||
################
|
||||
# build matrix #
|
||||
################
|
||||
@@ -129,27 +118,26 @@ matrix:
|
||||
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: xcode9.3
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode9.4
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode10
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode10.1
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode10.2
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode11.2
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode12
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode12
|
||||
env:
|
||||
- IMPLICIT_CONVERSIONS=OFF
|
||||
|
||||
# Linux / GCC
|
||||
|
||||
- os: linux
|
||||
@@ -212,7 +200,17 @@ matrix:
|
||||
compiler: gcc
|
||||
env:
|
||||
- COMPILER=g++-9
|
||||
- CXXFLAGS=-std=c++2a
|
||||
- IMPLICIT_CONVERSIONS=OFF
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-9', 'ninja-build']
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env:
|
||||
- COMPILER=g++-9
|
||||
- CXX_STANDARD=17
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
@@ -296,11 +294,11 @@ matrix:
|
||||
compiler: clang
|
||||
env:
|
||||
- COMPILER=clang++-7
|
||||
- CXXFLAGS=-std=c++1z
|
||||
- CXX_STANDARD=17
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7']
|
||||
packages: ['g++-6', 'clang-7', 'ninja-build']
|
||||
packages: ['g++-7', 'clang-7', 'ninja-build']
|
||||
|
||||
################
|
||||
# build script #
|
||||
@@ -320,10 +318,15 @@ script:
|
||||
- if [[ "${COMPILER}" != "" ]]; then export CXX=${COMPILER}; fi
|
||||
# by default, use the single-header version
|
||||
- if [[ "${MULTIPLE_HEADERS}" == "" ]]; then export MULTIPLE_HEADERS=OFF; fi
|
||||
# by default, use implicit conversions
|
||||
- if [[ "${IMPLICIT_CONVERSIONS}" == "" ]]; then export IMPLICIT_CONVERSIONS=ON; fi
|
||||
|
||||
# append CXX_STANDARD to CMAKE_OPTIONS if required
|
||||
- CMAKE_OPTIONS+=${CXX_STANDARD:+ -DCMAKE_CXX_STANDARD=$CXX_STANDARD -DCMAKE_CXX_STANDARD_REQUIRED=ON}
|
||||
|
||||
# compile and execute unit tests
|
||||
- mkdir -p build && cd build
|
||||
- cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -DJSON_BuildTests=On -GNinja && cmake --build . --config Release
|
||||
- cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -DJSON_ImplicitConversions=${IMPLICIT_CONVERSIONS} -DJSON_BuildTests=On -GNinja && cmake --build . --config Release
|
||||
- ctest -C Release --timeout 2700 -V -j
|
||||
- cd ..
|
||||
|
||||
|
||||
@@ -4,7 +4,16 @@ cmake_minimum_required(VERSION 3.1)
|
||||
## PROJECT
|
||||
## name and version
|
||||
##
|
||||
project(nlohmann_json VERSION 3.8.0 LANGUAGES CXX)
|
||||
project(nlohmann_json VERSION 3.9.1 LANGUAGES CXX)
|
||||
|
||||
##
|
||||
## MAIN_PROJECT CHECK
|
||||
## determine if nlohmann_json is built as a subproject (using add_subdirectory) or if it is the main project
|
||||
##
|
||||
set(MAIN_PROJECT OFF)
|
||||
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||
set(MAIN_PROJECT ON)
|
||||
endif()
|
||||
|
||||
##
|
||||
## INCLUDE
|
||||
@@ -15,9 +24,16 @@ include(ExternalProject)
|
||||
##
|
||||
## OPTIONS
|
||||
##
|
||||
option(JSON_BuildTests "Build the unit tests when BUILD_TESTING is enabled." ON)
|
||||
option(JSON_Install "Install CMake targets during install step." ON)
|
||||
|
||||
if (POLICY CMP0077)
|
||||
# Allow CMake 3.13+ to override options when using FetchContent / add_subdirectory.
|
||||
cmake_policy(SET CMP0077 NEW)
|
||||
endif ()
|
||||
|
||||
option(JSON_BuildTests "Build the unit tests when BUILD_TESTING is enabled." ${MAIN_PROJECT})
|
||||
option(JSON_Install "Install CMake targets during install step." ${MAIN_PROJECT})
|
||||
option(JSON_MultipleHeaders "Use non-amalgamated version of the library." OFF)
|
||||
option(JSON_ImplicitConversions "Enable implicit conversions." ON)
|
||||
|
||||
##
|
||||
## CONFIGURATION
|
||||
@@ -33,6 +49,7 @@ set(NLOHMANN_JSON_CMAKE_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
set(NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
|
||||
set(NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}Config.cmake")
|
||||
set(NLOHMANN_JSON_CMAKE_PROJECT_TARGETS_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}Targets.cmake")
|
||||
set(NLOHMANN_JSON_PKGCONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
|
||||
if (JSON_MultipleHeaders)
|
||||
set(NLOHMANN_JSON_INCLUDE_BUILD_DIR "${PROJECT_SOURCE_DIR}/include/")
|
||||
@@ -42,6 +59,10 @@ else()
|
||||
message(STATUS "Using the single-header code from ${NLOHMANN_JSON_INCLUDE_BUILD_DIR}")
|
||||
endif()
|
||||
|
||||
if (NOT JSON_ImplicitConversions)
|
||||
message(STATUS "Implicit conversions are disabled")
|
||||
endif()
|
||||
|
||||
##
|
||||
## TARGET
|
||||
## create target and add include path
|
||||
@@ -54,6 +75,12 @@ else()
|
||||
target_compile_features(${NLOHMANN_JSON_TARGET_NAME} INTERFACE cxx_std_11)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(
|
||||
${NLOHMANN_JSON_TARGET_NAME}
|
||||
INTERFACE
|
||||
JSON_USE_IMPLICIT_CONVERSIONS=$<BOOL:${JSON_ImplicitConversions}>
|
||||
)
|
||||
|
||||
target_include_directories(
|
||||
${NLOHMANN_JSON_TARGET_NAME}
|
||||
INTERFACE
|
||||
@@ -73,13 +100,18 @@ if (MSVC)
|
||||
)
|
||||
endif()
|
||||
|
||||
# Install a pkg-config file, so other tools can find this.
|
||||
CONFIGURE_FILE(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkg-config.pc.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
|
||||
)
|
||||
|
||||
##
|
||||
## TESTS
|
||||
## create and configure the unit test target
|
||||
##
|
||||
include(CTest) #adds option BUILD_TESTING (default ON)
|
||||
|
||||
if(BUILD_TESTING AND JSON_BuildTests)
|
||||
if (JSON_BuildTests)
|
||||
include(CTest)
|
||||
enable_testing()
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
@@ -133,4 +165,8 @@ endif()
|
||||
NAMESPACE ${PROJECT_NAME}::
|
||||
DESTINATION ${NLOHMANN_JSON_CONFIG_INSTALL_DIR}
|
||||
)
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
|
||||
DESTINATION ${NLOHMANN_JSON_PKGCONFIG_INSTALL_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
179
ChangeLog.md
179
ChangeLog.md
@@ -1,13 +1,151 @@
|
||||
# Changelog
|
||||
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [v3.9.1](https://github.com/nlohmann/json/releases/tag/v3.9.1) (2020-08-06)
|
||||
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v3.9.0...v3.9.1)
|
||||
|
||||
- Can't parse not formatted JSON. [\#2340](https://github.com/nlohmann/json/issues/2340)
|
||||
- parse returns desired array contained in array when JSON text begins with square bracket on gcc 7.5.0 [\#2339](https://github.com/nlohmann/json/issues/2339)
|
||||
- Unexpected deserialization difference between Mac and Linux [\#2338](https://github.com/nlohmann/json/issues/2338)
|
||||
- Reading ordered\_json from file causes compile error [\#2331](https://github.com/nlohmann/json/issues/2331)
|
||||
- ignore\_comment=true fails on multiple consecutive lines starting with comments [\#2330](https://github.com/nlohmann/json/issues/2330)
|
||||
- Update documentation about Homebrew installation and CMake integration - Homebrew [\#2326](https://github.com/nlohmann/json/issues/2326)
|
||||
- Chinese character initialize error [\#2325](https://github.com/nlohmann/json/issues/2325)
|
||||
- json.update and vector\<pair\>does not work with ordered\_json [\#2315](https://github.com/nlohmann/json/issues/2315)
|
||||
- Ambiguous call to overloaded function [\#2210](https://github.com/nlohmann/json/issues/2210)
|
||||
|
||||
- Fix fallthrough warning [\#2333](https://github.com/nlohmann/json/pull/2333) ([nlohmann](https://github.com/nlohmann))
|
||||
- Fix lexer to properly cope with repeated comments [\#2332](https://github.com/nlohmann/json/pull/2332) ([nlohmann](https://github.com/nlohmann))
|
||||
- Fix name of Homebrew formula in documentation [\#2327](https://github.com/nlohmann/json/pull/2327) ([nlohmann](https://github.com/nlohmann))
|
||||
- fix typo [\#2320](https://github.com/nlohmann/json/pull/2320) ([wx257osn2](https://github.com/wx257osn2))
|
||||
- Fix a bug due to missing overloads in ordered\_map container [\#2319](https://github.com/nlohmann/json/pull/2319) ([nlohmann](https://github.com/nlohmann))
|
||||
- cmake: install pkg-config file relative to current\_binary\_dir [\#2318](https://github.com/nlohmann/json/pull/2318) ([eli-schwartz](https://github.com/eli-schwartz))
|
||||
- Fixed installation of pkg-config file on other than Ubuntu [\#2314](https://github.com/nlohmann/json/pull/2314) ([xvitaly](https://github.com/xvitaly))
|
||||
- Cleanup [\#2303](https://github.com/nlohmann/json/pull/2303) ([nlohmann](https://github.com/nlohmann))
|
||||
|
||||
## [v3.9.0](https://github.com/nlohmann/json/releases/tag/v3.9.0) (2020-07-27)
|
||||
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v3.8.0...v3.9.0)
|
||||
|
||||
- Unknown Type Name clang error when using NLOHMANN\_DEFINE\_TYPE\_NON\_INTRUSIVE [\#2313](https://github.com/nlohmann/json/issues/2313)
|
||||
- Clang 10.0 / GCC 10.1 warnings on disabled exceptions [\#2304](https://github.com/nlohmann/json/issues/2304)
|
||||
- Application stalls indefinitely with message byte size 10 [\#2293](https://github.com/nlohmann/json/issues/2293)
|
||||
- linker error [\#2292](https://github.com/nlohmann/json/issues/2292)
|
||||
- Add support for high-precision numbers in UBJSON encoding [\#2286](https://github.com/nlohmann/json/issues/2286)
|
||||
- NLOHMANN\_DEFINE\_TYPE\_NON\_INTRUSIVE fails if the length of the argument is 10 [\#2280](https://github.com/nlohmann/json/issues/2280)
|
||||
- Custom types : MACRO expansion bug [\#2267](https://github.com/nlohmann/json/issues/2267)
|
||||
- to/from\_json Failing To Convert String [\#2238](https://github.com/nlohmann/json/issues/2238)
|
||||
- clang 9.0 report warning: unused type alias 'size\_type' \[-Wunused-local-typedef\] [\#2221](https://github.com/nlohmann/json/issues/2221)
|
||||
- Enormous array created when working with map\<int,T\> [\#2220](https://github.com/nlohmann/json/issues/2220)
|
||||
- Can I disable sorting of json values [\#2219](https://github.com/nlohmann/json/issues/2219)
|
||||
- Getting Qt types to work [\#2217](https://github.com/nlohmann/json/issues/2217)
|
||||
- Convert to Qt QVariant [\#2216](https://github.com/nlohmann/json/issues/2216)
|
||||
- How to custom serialize same data type of vector? [\#2215](https://github.com/nlohmann/json/issues/2215)
|
||||
- json constructor does not support std::optional [\#2214](https://github.com/nlohmann/json/issues/2214)
|
||||
- Failing to Parse Valid JSON [\#2209](https://github.com/nlohmann/json/issues/2209)
|
||||
- \(De-\)Serialization of std::variant with namespaces [\#2208](https://github.com/nlohmann/json/issues/2208)
|
||||
- Addint support for complex type [\#2207](https://github.com/nlohmann/json/issues/2207)
|
||||
- array\_index possible out of range [\#2205](https://github.com/nlohmann/json/issues/2205)
|
||||
- Object deserialized as array [\#2204](https://github.com/nlohmann/json/issues/2204)
|
||||
- Sending to a function a reference to a sub-branch [\#2200](https://github.com/nlohmann/json/issues/2200)
|
||||
- How to Serialize derived class to JSON object? [\#2199](https://github.com/nlohmann/json/issues/2199)
|
||||
- JSON incorrectly serialized [\#2198](https://github.com/nlohmann/json/issues/2198)
|
||||
- Exception Unhandled out\_of\_range error [\#2197](https://github.com/nlohmann/json/issues/2197)
|
||||
- msgpack serialisation : float is treated as 64bit float, not 32bit float. [\#2196](https://github.com/nlohmann/json/issues/2196)
|
||||
- Is it possible to use compile-time type guarantees for JSON structures? [\#2195](https://github.com/nlohmann/json/issues/2195)
|
||||
- Question : performance against python dict [\#2194](https://github.com/nlohmann/json/issues/2194)
|
||||
- vs2017 compile error [\#2192](https://github.com/nlohmann/json/issues/2192)
|
||||
- Check if a key exists [\#2191](https://github.com/nlohmann/json/issues/2191)
|
||||
- Failed to run tests due to missing test data on builders without Internet access [\#2190](https://github.com/nlohmann/json/issues/2190)
|
||||
- 3.8.0: unit-cbor.cpp test failures [\#2189](https://github.com/nlohmann/json/issues/2189)
|
||||
- 'nlohmann/json.hpp' file not found [\#2188](https://github.com/nlohmann/json/issues/2188)
|
||||
- How to send json data over the wire? [\#2185](https://github.com/nlohmann/json/issues/2185)
|
||||
- Ubuntu 16 not supporting nlohmann/json? [\#2184](https://github.com/nlohmann/json/issues/2184)
|
||||
- .get\<std::string\> causing emdash errors [\#2180](https://github.com/nlohmann/json/issues/2180)
|
||||
- Object properties should not be re-sorted alphabetically [\#2179](https://github.com/nlohmann/json/issues/2179)
|
||||
- Custom type registration : instrusive API [\#2175](https://github.com/nlohmann/json/issues/2175)
|
||||
- Many version of the function "void to\_json\(json& j, const MyStruct& struct\)" [\#2171](https://github.com/nlohmann/json/issues/2171)
|
||||
- How should strings be escaped? [\#2155](https://github.com/nlohmann/json/issues/2155)
|
||||
- Adding a value to an existing json puts it at the beginning instead of the end [\#2149](https://github.com/nlohmann/json/issues/2149)
|
||||
- The header file is big, can we use what we need. [\#2134](https://github.com/nlohmann/json/issues/2134)
|
||||
- Changing the default format for unordered\_map \(or other set\) [\#2132](https://github.com/nlohmann/json/issues/2132)
|
||||
- Getting size of deserialized bson document [\#2131](https://github.com/nlohmann/json/issues/2131)
|
||||
- implicit conversion failure [\#2128](https://github.com/nlohmann/json/issues/2128)
|
||||
- Error thrown when parsing in a subclass [\#2124](https://github.com/nlohmann/json/issues/2124)
|
||||
- explicit conversion to string not considered for std::map keys in GCC8 [\#2096](https://github.com/nlohmann/json/issues/2096)
|
||||
- Add support for JSONC [\#2061](https://github.com/nlohmann/json/issues/2061)
|
||||
- Library provides template arg for string\_type but assumes std::string in some places [\#2059](https://github.com/nlohmann/json/issues/2059)
|
||||
- incremental parsing with sax\_parser [\#2030](https://github.com/nlohmann/json/issues/2030)
|
||||
- Question about flatten and unflatten [\#1989](https://github.com/nlohmann/json/issues/1989)
|
||||
- CBOR parser doesn't skip tags [\#1968](https://github.com/nlohmann/json/issues/1968)
|
||||
- Compilation failure using Clang on Windows [\#1898](https://github.com/nlohmann/json/issues/1898)
|
||||
- Fail to build when including json.hpp as a system include [\#1818](https://github.com/nlohmann/json/issues/1818)
|
||||
- Parsing string into json doesn't preserve the order correctly. [\#1817](https://github.com/nlohmann/json/issues/1817)
|
||||
- \[C++17\] Allow std::optional to convert to nlohmann::json [\#1749](https://github.com/nlohmann/json/issues/1749)
|
||||
- How can I save json object in file in order? [\#1717](https://github.com/nlohmann/json/issues/1717)
|
||||
- Support for Comments [\#1513](https://github.com/nlohmann/json/issues/1513)
|
||||
- clang compiler: error : unknown type name 'not' [\#1119](https://github.com/nlohmann/json/issues/1119)
|
||||
- dump\(\) without alphabetical order [\#1106](https://github.com/nlohmann/json/issues/1106)
|
||||
- operator T\(\) considered harmful [\#958](https://github.com/nlohmann/json/issues/958)
|
||||
- Order of the elements in JSON object [\#952](https://github.com/nlohmann/json/issues/952)
|
||||
- How to prevent alphabetical sorting of data? [\#727](https://github.com/nlohmann/json/issues/727)
|
||||
- Why is an object ordering values by Alphabetical Order? [\#660](https://github.com/nlohmann/json/issues/660)
|
||||
- Feature request: Comments [\#597](https://github.com/nlohmann/json/issues/597)
|
||||
- Head Elements Sorting [\#543](https://github.com/nlohmann/json/issues/543)
|
||||
- Automatic ordered JSON [\#424](https://github.com/nlohmann/json/issues/424)
|
||||
- Support for comments. [\#376](https://github.com/nlohmann/json/issues/376)
|
||||
- Optional comment support. [\#363](https://github.com/nlohmann/json/issues/363)
|
||||
- Strip comments / Minify [\#294](https://github.com/nlohmann/json/issues/294)
|
||||
- maintaining order of keys during iteration [\#106](https://github.com/nlohmann/json/issues/106)
|
||||
|
||||
- Update documentation [\#2312](https://github.com/nlohmann/json/pull/2312) ([nlohmann](https://github.com/nlohmann))
|
||||
- Fix bug in CBOR tag handling [\#2308](https://github.com/nlohmann/json/pull/2308) ([nlohmann](https://github.com/nlohmann))
|
||||
- added inline to NLOHMANN\_DEFINE\_TYPE\_NON\_INTRUSIVE macro [\#2306](https://github.com/nlohmann/json/pull/2306) ([jwittbrodt](https://github.com/jwittbrodt))
|
||||
- fixes unused variable 'ex' for \#2304 [\#2305](https://github.com/nlohmann/json/pull/2305) ([AODQ](https://github.com/AODQ))
|
||||
- Add test with multiple translation units [\#2301](https://github.com/nlohmann/json/pull/2301) ([nlohmann](https://github.com/nlohmann))
|
||||
- Merge GitHub actions [\#2300](https://github.com/nlohmann/json/pull/2300) ([nlohmann](https://github.com/nlohmann))
|
||||
- Fix unused parameter [\#2299](https://github.com/nlohmann/json/pull/2299) ([nlohmann](https://github.com/nlohmann))
|
||||
- Add support for high-precision numbers in UBJSON encoding [\#2297](https://github.com/nlohmann/json/pull/2297) ([nlohmann](https://github.com/nlohmann))
|
||||
- fix eof for get\_binary and get\_string [\#2294](https://github.com/nlohmann/json/pull/2294) ([jprochazk](https://github.com/jprochazk))
|
||||
- Serialisation macros: increase upper bound on number of member variables [\#2287](https://github.com/nlohmann/json/pull/2287) ([pfeatherstone](https://github.com/pfeatherstone))
|
||||
- add inline specifier for detail::combine [\#2285](https://github.com/nlohmann/json/pull/2285) ([T0b1-iOS](https://github.com/T0b1-iOS))
|
||||
- Add static assertion for missing binary function in SAX interface [\#2282](https://github.com/nlohmann/json/pull/2282) ([nlohmann](https://github.com/nlohmann))
|
||||
- Add test for target\_include\_directories [\#2279](https://github.com/nlohmann/json/pull/2279) ([nlohmann](https://github.com/nlohmann))
|
||||
- Clean up maintainer Makefiles and fix some linter warnings [\#2274](https://github.com/nlohmann/json/pull/2274) ([nlohmann](https://github.com/nlohmann))
|
||||
- Add option to ignore CBOR tags [\#2273](https://github.com/nlohmann/json/pull/2273) ([nlohmann](https://github.com/nlohmann))
|
||||
- Hash function without allocation [\#2269](https://github.com/nlohmann/json/pull/2269) ([nlohmann](https://github.com/nlohmann))
|
||||
- Add ClangCL for MSVC [\#2268](https://github.com/nlohmann/json/pull/2268) ([t-b](https://github.com/t-b))
|
||||
- Makefile: Always use SED variable [\#2264](https://github.com/nlohmann/json/pull/2264) ([t-b](https://github.com/t-b))
|
||||
- Add Xcode 12 CI [\#2262](https://github.com/nlohmann/json/pull/2262) ([nlohmann](https://github.com/nlohmann))
|
||||
- Make library work with Clang on Windows [\#2259](https://github.com/nlohmann/json/pull/2259) ([nlohmann](https://github.com/nlohmann))
|
||||
- Add ordered\_json specialization with ordered object keys [\#2258](https://github.com/nlohmann/json/pull/2258) ([nlohmann](https://github.com/nlohmann))
|
||||
- Add pkg-config file [\#2253](https://github.com/nlohmann/json/pull/2253) ([ericonr](https://github.com/ericonr))
|
||||
- Fix regression from \#2181 [\#2251](https://github.com/nlohmann/json/pull/2251) ([nlohmann](https://github.com/nlohmann))
|
||||
- Tag binary values in cbor if set [\#2244](https://github.com/nlohmann/json/pull/2244) ([matthewbauer](https://github.com/matthewbauer))
|
||||
- Make assert configurable via JSON\_ASSERT [\#2242](https://github.com/nlohmann/json/pull/2242) ([nlohmann](https://github.com/nlohmann))
|
||||
- Add specialization of get\_to [\#2233](https://github.com/nlohmann/json/pull/2233) ([nlohmann](https://github.com/nlohmann))
|
||||
- Refine documentation of error\_handler parameter [\#2232](https://github.com/nlohmann/json/pull/2232) ([nlohmann](https://github.com/nlohmann))
|
||||
- Simplify conversion from/to custom types [\#2225](https://github.com/nlohmann/json/pull/2225) ([nlohmann](https://github.com/nlohmann))
|
||||
- Remove unused typedefs [\#2224](https://github.com/nlohmann/json/pull/2224) ([nlohmann](https://github.com/nlohmann))
|
||||
- Enable CMake policy CMP0077 [\#2222](https://github.com/nlohmann/json/pull/2222) ([alexreinking](https://github.com/alexreinking))
|
||||
- Add option to ignore comments in parse/accept functions [\#2212](https://github.com/nlohmann/json/pull/2212) ([nlohmann](https://github.com/nlohmann))
|
||||
- Fix Clang-Tidy warnings [\#2211](https://github.com/nlohmann/json/pull/2211) ([nlohmann](https://github.com/nlohmann))
|
||||
- Simple ordered\_json that works on all supported compilers [\#2206](https://github.com/nlohmann/json/pull/2206) ([gatopeich](https://github.com/gatopeich))
|
||||
- Use unsigned indizies for array index in json pointer [\#2203](https://github.com/nlohmann/json/pull/2203) ([t-b](https://github.com/t-b))
|
||||
- Add option to not rely on Internet connectivity during test stage [\#2202](https://github.com/nlohmann/json/pull/2202) ([nlohmann](https://github.com/nlohmann))
|
||||
- Serialize floating-point numbers with 32 bit when possible \(MessagePack\) [\#2201](https://github.com/nlohmann/json/pull/2201) ([nlohmann](https://github.com/nlohmann))
|
||||
- Fix consistency in function `int\_to\_string\(\)` [\#2193](https://github.com/nlohmann/json/pull/2193) ([dota17](https://github.com/dota17))
|
||||
- Fix issue\#1275 [\#2181](https://github.com/nlohmann/json/pull/2181) ([dota17](https://github.com/dota17))
|
||||
- C++20 support by removing swap specialization [\#2176](https://github.com/nlohmann/json/pull/2176) ([gracicot](https://github.com/gracicot))
|
||||
- Feat/explicit conversion operator [\#1559](https://github.com/nlohmann/json/pull/1559) ([theodelrieu](https://github.com/theodelrieu))
|
||||
|
||||
## [v3.8.0](https://github.com/nlohmann/json/releases/tag/v3.8.0) (2020-06-14)
|
||||
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v3.7.3...v3.8.0)
|
||||
|
||||
- sorry delete this issue, i'm stupid [\#2187](https://github.com/nlohmann/json/issues/2187)
|
||||
- Append to a std::nlohmann::json type [\#2186](https://github.com/nlohmann/json/issues/2186)
|
||||
- Object properties should not be re-sorted alphabetically [\#2179](https://github.com/nlohmann/json/issues/2179)
|
||||
- Some troubles to compile the last revision [\#2177](https://github.com/nlohmann/json/issues/2177)
|
||||
- \# Top level CMakeLists.txt
|
||||
project\(FOO\)
|
||||
@@ -34,7 +172,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- test-cbor fails [\#2154](https://github.com/nlohmann/json/issues/2154)
|
||||
- Accessing array inside array syntax? [\#2151](https://github.com/nlohmann/json/issues/2151)
|
||||
- Best way to catch errors when querying json [\#2150](https://github.com/nlohmann/json/issues/2150)
|
||||
- Adding a value to an existing json puts it at the beginning instead of the end [\#2149](https://github.com/nlohmann/json/issues/2149)
|
||||
- JSON Data Mapping Key-Value from other Key-Value [\#2148](https://github.com/nlohmann/json/issues/2148)
|
||||
- Conflicts with std \<any\> compiling with GCC 10 [\#2146](https://github.com/nlohmann/json/issues/2146)
|
||||
- Incorrect CMake FetchContent example [\#2142](https://github.com/nlohmann/json/issues/2142)
|
||||
@@ -64,7 +201,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Can't ad an object in another objet [\#2101](https://github.com/nlohmann/json/issues/2101)
|
||||
- Implicit conversion causes "cannot use operator\[\] with a string argument with string" [\#2098](https://github.com/nlohmann/json/issues/2098)
|
||||
- C++20: char8\_t [\#2097](https://github.com/nlohmann/json/issues/2097)
|
||||
- UTF8 [\#2095](https://github.com/nlohmann/json/issues/2095)
|
||||
- Compilation issues when included in project [\#2094](https://github.com/nlohmann/json/issues/2094)
|
||||
- string value with null character causes infinite loop [\#2093](https://github.com/nlohmann/json/issues/2093)
|
||||
- corrupted size vs. prev\_size \(aborted\) [\#2092](https://github.com/nlohmann/json/issues/2092)
|
||||
@@ -91,7 +227,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Bug: returning reference to local temporary object [\#2064](https://github.com/nlohmann/json/issues/2064)
|
||||
- Allow to use non strict parsing [\#2063](https://github.com/nlohmann/json/issues/2063)
|
||||
- Crashing on json::at [\#2062](https://github.com/nlohmann/json/issues/2062)
|
||||
- Add support for JSONC [\#2061](https://github.com/nlohmann/json/issues/2061)
|
||||
- How to convert a const std::vector\<char8\_t\> message to a json, to be able to parse it and extract information from it? Can you point to any examples? [\#2058](https://github.com/nlohmann/json/issues/2058)
|
||||
- Nice library [\#2057](https://github.com/nlohmann/json/issues/2057)
|
||||
- json.hpp:15372:22: error: expected unqualified-id if \(not std::isfinite\(x\)\): Started getting this bug after updating my XCode [\#2056](https://github.com/nlohmann/json/issues/2056)
|
||||
@@ -197,7 +332,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- typo in a comment [\#1903](https://github.com/nlohmann/json/issues/1903)
|
||||
- Watch JSON variables in Debug [\#1902](https://github.com/nlohmann/json/issues/1902)
|
||||
- does Json sdk cares about dfc dfd utf8 issue? [\#1901](https://github.com/nlohmann/json/issues/1901)
|
||||
- Compilation failure using Clang on Windows [\#1898](https://github.com/nlohmann/json/issues/1898)
|
||||
- Allow multiple line string value in JSON [\#1897](https://github.com/nlohmann/json/issues/1897)
|
||||
- Writing map to json file [\#1896](https://github.com/nlohmann/json/issues/1896)
|
||||
- Small documentation mistake [\#1895](https://github.com/nlohmann/json/issues/1895)
|
||||
@@ -253,7 +387,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Serialize big data in json [\#1828](https://github.com/nlohmann/json/issues/1828)
|
||||
- Backslash '\' in value causes exception [\#1827](https://github.com/nlohmann/json/issues/1827)
|
||||
- from\_json for non default constructible class with dependency injection [\#1819](https://github.com/nlohmann/json/issues/1819)
|
||||
- Fail to build when including json.hpp as a system include [\#1818](https://github.com/nlohmann/json/issues/1818)
|
||||
- Semi-frequent timeouts in `test-unicode\_all` with 3.6.1 \(aarch64\) [\#1816](https://github.com/nlohmann/json/issues/1816)
|
||||
- input\_adapter not user extensible [\#1813](https://github.com/nlohmann/json/issues/1813)
|
||||
- crash at json::destroy on android [\#1812](https://github.com/nlohmann/json/issues/1812)
|
||||
@@ -322,7 +455,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Fix issue\#1719 [\#2044](https://github.com/nlohmann/json/pull/2044) ([dota17](https://github.com/dota17))
|
||||
- Add missing testcase about NaN in unit-constructor1.cpp [\#2043](https://github.com/nlohmann/json/pull/2043) ([dota17](https://github.com/dota17))
|
||||
- Templatize basic\_json constructor from json\_ref [\#2034](https://github.com/nlohmann/json/pull/2034) ([ArtemSarmini](https://github.com/ArtemSarmini))
|
||||
- Replace deprecated std::is\_pod [\#2033](https://github.com/nlohmann/json/pull/2033) ([nlohmann](https://github.com/nlohmann))
|
||||
- fix \#1982:json\_pointer.contains\(\) exception is incorrectly raised [\#2019](https://github.com/nlohmann/json/pull/2019) ([dota17](https://github.com/dota17))
|
||||
- catch exceptions for json\_pointer : ..../+99 [\#1990](https://github.com/nlohmann/json/pull/1990) ([dota17](https://github.com/dota17))
|
||||
- fix warnings in serializer.hpp for VS2019 [\#1969](https://github.com/nlohmann/json/pull/1969) ([dota17](https://github.com/dota17))
|
||||
@@ -369,7 +501,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- json class should have a get\_or member function [\#1823](https://github.com/nlohmann/json/issues/1823)
|
||||
- NLOHMANN\_JSON\_SERIALIZE\_ENUM macro capture's json objects by value [\#1822](https://github.com/nlohmann/json/issues/1822)
|
||||
- Parse fails when number literals start with zero [\#1820](https://github.com/nlohmann/json/issues/1820)
|
||||
- Parsing string into json doesn't preserve the order correctly. [\#1817](https://github.com/nlohmann/json/issues/1817)
|
||||
- Weird behaviour of `contains` with `json\_pointer` [\#1815](https://github.com/nlohmann/json/issues/1815)
|
||||
- strange behaviour with json\_pointer and .contains\(\) [\#1811](https://github.com/nlohmann/json/issues/1811)
|
||||
- Can \#1695 be re-opened? [\#1808](https://github.com/nlohmann/json/issues/1808)
|
||||
@@ -426,7 +557,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- CMake not correctly finding the configuration package for 3.7.0 [\#1721](https://github.com/nlohmann/json/issues/1721)
|
||||
- name typo in the "spack package management" section of README.md [\#1720](https://github.com/nlohmann/json/issues/1720)
|
||||
- How to add json to another json? [\#1718](https://github.com/nlohmann/json/issues/1718)
|
||||
- How can I save json object in file in order? [\#1717](https://github.com/nlohmann/json/issues/1717)
|
||||
- json::parse\(\) ubsan regression with v3.7.0 [\#1716](https://github.com/nlohmann/json/issues/1716)
|
||||
- What I am doing wrong?!? [\#1714](https://github.com/nlohmann/json/issues/1714)
|
||||
- Potential memory leak detected by Valgrind [\#1713](https://github.com/nlohmann/json/issues/1713)
|
||||
@@ -658,7 +788,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- how to precision to four decimal for double when use to\_json [\#1519](https://github.com/nlohmann/json/issues/1519)
|
||||
- error parse [\#1518](https://github.com/nlohmann/json/issues/1518)
|
||||
- Compile error: template argument deduction/substitution failed [\#1515](https://github.com/nlohmann/json/issues/1515)
|
||||
- Support for Comments [\#1513](https://github.com/nlohmann/json/issues/1513)
|
||||
- std::complex type [\#1510](https://github.com/nlohmann/json/issues/1510)
|
||||
- CBOR byte string support [\#1509](https://github.com/nlohmann/json/issues/1509)
|
||||
- Compilation error getting a std::pair\<\> on latest VS 2017 compiler [\#1506](https://github.com/nlohmann/json/issues/1506)
|
||||
@@ -763,6 +892,7 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Fix x64 target platform for appveyor [\#1414](https://github.com/nlohmann/json/pull/1414) ([nickaein](https://github.com/nickaein))
|
||||
- Improve dump\_integer performance [\#1411](https://github.com/nlohmann/json/pull/1411) ([nickaein](https://github.com/nickaein))
|
||||
- buildsystem: relax requirement on cmake version [\#1409](https://github.com/nlohmann/json/pull/1409) ([yann-morin-1998](https://github.com/yann-morin-1998))
|
||||
- Added Support for Structured Bindings [\#1391](https://github.com/nlohmann/json/pull/1391) ([pratikpc](https://github.com/pratikpc))
|
||||
- CMake: Optional Install if Embedded [\#1330](https://github.com/nlohmann/json/pull/1330) ([ax3l](https://github.com/ax3l))
|
||||
|
||||
## [v3.5.0](https://github.com/nlohmann/json/releases/tag/v3.5.0) (2018-12-21)
|
||||
@@ -824,7 +954,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Comparisons between large unsigned and negative signed integers [\#1295](https://github.com/nlohmann/json/issues/1295)
|
||||
- CMake alias to `nlohmann::json` [\#1291](https://github.com/nlohmann/json/issues/1291)
|
||||
- Release zips without tests [\#1285](https://github.com/nlohmann/json/issues/1285)
|
||||
- Suggestion to improve value\(\) accessors with respect to move semantics [\#1275](https://github.com/nlohmann/json/issues/1275)
|
||||
- separate object\_t::key\_type from basic\_json::key\_type, and use an allocator which returns object\_t::key\_type [\#1274](https://github.com/nlohmann/json/issues/1274)
|
||||
- Is there a nice way to associate external values with json elements? [\#1256](https://github.com/nlohmann/json/issues/1256)
|
||||
- Delete by json\_pointer [\#1248](https://github.com/nlohmann/json/issues/1248)
|
||||
@@ -833,7 +962,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Check value for existence by json\_pointer [\#1194](https://github.com/nlohmann/json/issues/1194)
|
||||
|
||||
- Feature/add file input adapter [\#1392](https://github.com/nlohmann/json/pull/1392) ([dumarjo](https://github.com/dumarjo))
|
||||
- Added Support for Structured Bindings [\#1391](https://github.com/nlohmann/json/pull/1391) ([pratikpc](https://github.com/pratikpc))
|
||||
- Link to issue \#958 broken [\#1382](https://github.com/nlohmann/json/pull/1382) ([kjpus](https://github.com/kjpus))
|
||||
- readme: fix typo [\#1380](https://github.com/nlohmann/json/pull/1380) ([manu-chroma](https://github.com/manu-chroma))
|
||||
- recommend using explicit from JSON conversions [\#1363](https://github.com/nlohmann/json/pull/1363) ([theodelrieu](https://github.com/theodelrieu))
|
||||
@@ -842,6 +970,7 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Set eofbit on exhausted input stream. [\#1343](https://github.com/nlohmann/json/pull/1343) ([mefyl](https://github.com/mefyl))
|
||||
- Add a SFINAE friendly iterator\_traits and use that instead. [\#1342](https://github.com/nlohmann/json/pull/1342) ([dgavedissian](https://github.com/dgavedissian))
|
||||
- Fix EOL Whitespaces & CMake Spelling [\#1329](https://github.com/nlohmann/json/pull/1329) ([ax3l](https://github.com/ax3l))
|
||||
- Add BSON support [\#1320](https://github.com/nlohmann/json/pull/1320) ([nlohmann](https://github.com/nlohmann))
|
||||
|
||||
## [v3.4.0](https://github.com/nlohmann/json/releases/tag/v3.4.0) (2018-10-30)
|
||||
|
||||
@@ -881,7 +1010,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Soften the landing when dumping non-UTF8 strings \(type\_error.316 exception\) [\#1198](https://github.com/nlohmann/json/issues/1198)
|
||||
|
||||
- Add macro to define enum/JSON mapping [\#1323](https://github.com/nlohmann/json/pull/1323) ([nlohmann](https://github.com/nlohmann))
|
||||
- Add BSON support [\#1320](https://github.com/nlohmann/json/pull/1320) ([nlohmann](https://github.com/nlohmann))
|
||||
- Properly convert constants to CharType [\#1315](https://github.com/nlohmann/json/pull/1315) ([nlohmann](https://github.com/nlohmann))
|
||||
- Allow to set error handler for decoding errors [\#1314](https://github.com/nlohmann/json/pull/1314) ([nlohmann](https://github.com/nlohmann))
|
||||
- Add Meson related info to README [\#1305](https://github.com/nlohmann/json/pull/1305) ([koponomarenko](https://github.com/koponomarenko))
|
||||
@@ -1023,7 +1151,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- can't not parse "\\“ string [\#1123](https://github.com/nlohmann/json/issues/1123)
|
||||
- if json file contain Internationalization chars , get exception [\#1122](https://github.com/nlohmann/json/issues/1122)
|
||||
- How to use a json::iterator dereferenced value in code? [\#1120](https://github.com/nlohmann/json/issues/1120)
|
||||
- clang compiler: error : unknown type name 'not' [\#1119](https://github.com/nlohmann/json/issues/1119)
|
||||
- Disable implicit conversions from json to std::initializer\_list\<T\> for any T [\#1118](https://github.com/nlohmann/json/issues/1118)
|
||||
- Implicit conversions to complex types can lead to surprising and confusing errors [\#1116](https://github.com/nlohmann/json/issues/1116)
|
||||
- How can I write from\_json for a complex datatype that is not default constructible? [\#1115](https://github.com/nlohmann/json/issues/1115)
|
||||
@@ -1035,7 +1162,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- JSON representation for floating point values has too many digits [\#1109](https://github.com/nlohmann/json/issues/1109)
|
||||
- Not working for classes containing "\_declspec\(dllimport\)" in their declaration [\#1108](https://github.com/nlohmann/json/issues/1108)
|
||||
- Get keys from json object [\#1107](https://github.com/nlohmann/json/issues/1107)
|
||||
- dump\(\) without alphabetical order [\#1106](https://github.com/nlohmann/json/issues/1106)
|
||||
- Cannot deserialize types using std::ratio [\#1105](https://github.com/nlohmann/json/issues/1105)
|
||||
- i want to learn json [\#1104](https://github.com/nlohmann/json/issues/1104)
|
||||
- Type checking during compile [\#1103](https://github.com/nlohmann/json/issues/1103)
|
||||
@@ -1182,6 +1308,7 @@ All notable changes to this project will be documented in this file. This projec
|
||||
|
||||
- Allowing for user-defined string type in lexer/parser [\#1009](https://github.com/nlohmann/json/pull/1009) ([nlohmann](https://github.com/nlohmann))
|
||||
- dump to alternative string type, as defined in basic\_json template [\#1006](https://github.com/nlohmann/json/pull/1006) ([agrianius](https://github.com/agrianius))
|
||||
- Fix memory leak during parser callback [\#1001](https://github.com/nlohmann/json/pull/1001) ([nlohmann](https://github.com/nlohmann))
|
||||
- fixed misprinted condition detected by PVS Studio. [\#992](https://github.com/nlohmann/json/pull/992) ([bogemic](https://github.com/bogemic))
|
||||
- Fix/basic json conversion [\#986](https://github.com/nlohmann/json/pull/986) ([theodelrieu](https://github.com/theodelrieu))
|
||||
- Make integration section concise [\#981](https://github.com/nlohmann/json/pull/981) ([wla80](https://github.com/wla80))
|
||||
@@ -1205,7 +1332,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- \[Request\] Macro generating from\_json\(\) and to\_json\(\) [\#895](https://github.com/nlohmann/json/issues/895)
|
||||
- basic\_json::value throws exception instead of returning default value [\#871](https://github.com/nlohmann/json/issues/871)
|
||||
|
||||
- Fix memory leak during parser callback [\#1001](https://github.com/nlohmann/json/pull/1001) ([nlohmann](https://github.com/nlohmann))
|
||||
- Fix constraints on from\_json\(CompatibleArrayType\) [\#969](https://github.com/nlohmann/json/pull/969) ([theodelrieu](https://github.com/theodelrieu))
|
||||
- Make coveralls watch the include folder [\#957](https://github.com/nlohmann/json/pull/957) ([theodelrieu](https://github.com/theodelrieu))
|
||||
- Fix links in README.md [\#955](https://github.com/nlohmann/json/pull/955) ([patrikhuber](https://github.com/patrikhuber))
|
||||
@@ -1219,7 +1345,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v3.0.1...3.1.0)
|
||||
|
||||
- Order of the elements in JSON object [\#952](https://github.com/nlohmann/json/issues/952)
|
||||
- I have a proposal [\#949](https://github.com/nlohmann/json/issues/949)
|
||||
- VERSION define\(s\) [\#948](https://github.com/nlohmann/json/issues/948)
|
||||
- v3.0.1 compile error in icc 16.0.4 [\#947](https://github.com/nlohmann/json/issues/947)
|
||||
@@ -1421,7 +1546,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Project's name is too generic and hard to search for [\#730](https://github.com/nlohmann/json/issues/730)
|
||||
- Visual Studio 2015 IntelliTrace problems [\#729](https://github.com/nlohmann/json/issues/729)
|
||||
- How to erase nested objects inside other objects? [\#728](https://github.com/nlohmann/json/issues/728)
|
||||
- How to prevent alphabetical sorting of data? [\#727](https://github.com/nlohmann/json/issues/727)
|
||||
- Serialization for CBOR [\#726](https://github.com/nlohmann/json/issues/726)
|
||||
- Using json Object as value in a map [\#725](https://github.com/nlohmann/json/issues/725)
|
||||
- std::regex and nlohmann::json value [\#724](https://github.com/nlohmann/json/issues/724)
|
||||
@@ -1469,7 +1593,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- could this json lib work on windows? [\#664](https://github.com/nlohmann/json/issues/664)
|
||||
- How does from\_json work? [\#662](https://github.com/nlohmann/json/issues/662)
|
||||
- insert\(or merge\) object should replace same key , not ignore [\#661](https://github.com/nlohmann/json/issues/661)
|
||||
- Why is an object ordering values by Alphabetical Order? [\#660](https://github.com/nlohmann/json/issues/660)
|
||||
- Parse method doesn't handle newlines. [\#659](https://github.com/nlohmann/json/issues/659)
|
||||
- Compilation "note" on GCC 6 ARM [\#658](https://github.com/nlohmann/json/issues/658)
|
||||
- Adding additional push\_back/operator+= rvalue overloads for JSON object [\#657](https://github.com/nlohmann/json/issues/657)
|
||||
@@ -1519,7 +1642,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Use of the binary type in CBOR and Message Pack [\#601](https://github.com/nlohmann/json/issues/601)
|
||||
- Newbie issue: how does one convert a map in Json back to std::map? [\#600](https://github.com/nlohmann/json/issues/600)
|
||||
- Plugin system [\#599](https://github.com/nlohmann/json/issues/599)
|
||||
- Feature request: Comments [\#597](https://github.com/nlohmann/json/issues/597)
|
||||
- Using custom types for scalars? [\#596](https://github.com/nlohmann/json/issues/596)
|
||||
- Issues with the arithmetic in iterator and reverse iterator [\#593](https://github.com/nlohmann/json/issues/593)
|
||||
- not enough examples [\#592](https://github.com/nlohmann/json/issues/592)
|
||||
@@ -1561,7 +1683,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Ambiguous compare operators with clang-5.0 [\#547](https://github.com/nlohmann/json/issues/547)
|
||||
- Using tsl::ordered\_map [\#546](https://github.com/nlohmann/json/issues/546)
|
||||
- Compiler support errors are inconvenient [\#544](https://github.com/nlohmann/json/issues/544)
|
||||
- Head Elements Sorting [\#543](https://github.com/nlohmann/json/issues/543)
|
||||
- Duplicate symbols error happens while to\_json/from\_json method implemented inside entity definition header file [\#542](https://github.com/nlohmann/json/issues/542)
|
||||
- consider adding a bool json::is\_valid\(std::string const&\) non-member function [\#541](https://github.com/nlohmann/json/issues/541)
|
||||
- Help request [\#539](https://github.com/nlohmann/json/issues/539)
|
||||
@@ -1730,7 +1851,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Getting std::invalid\_argument: stream error when following example [\#429](https://github.com/nlohmann/json/issues/429)
|
||||
- Forward declare-only header? [\#427](https://github.com/nlohmann/json/issues/427)
|
||||
- Implicit conversion from array to object [\#425](https://github.com/nlohmann/json/issues/425)
|
||||
- Automatic ordered JSON [\#424](https://github.com/nlohmann/json/issues/424)
|
||||
- error C4996: 'strerror' when reading file [\#422](https://github.com/nlohmann/json/issues/422)
|
||||
- Get an error - JSON pointer must be empty or begin with '/' [\#421](https://github.com/nlohmann/json/issues/421)
|
||||
- size parameter for parse\(\) [\#419](https://github.com/nlohmann/json/issues/419)
|
||||
@@ -1739,7 +1859,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- comparing to 0 literal [\#414](https://github.com/nlohmann/json/issues/414)
|
||||
- Single char converted to ASCII code instead of string [\#413](https://github.com/nlohmann/json/issues/413)
|
||||
- How to know if a string was parsed as utf-8? [\#406](https://github.com/nlohmann/json/issues/406)
|
||||
- Heap-buffer-overflow \(OSS-Fuzz issue 342\) [\#405](https://github.com/nlohmann/json/issues/405)
|
||||
- Overloaded += to add objects to an array makes no sense? [\#404](https://github.com/nlohmann/json/issues/404)
|
||||
- Finding a value in an array [\#399](https://github.com/nlohmann/json/issues/399)
|
||||
- add release information in static function [\#397](https://github.com/nlohmann/json/issues/397)
|
||||
@@ -1769,6 +1888,7 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Use-of-uninitialized-value \(OSS-Fuzz issue 347\) [\#409](https://github.com/nlohmann/json/issues/409)
|
||||
- Heap-buffer-overflow \(OSS-Fuzz issue 344\) [\#408](https://github.com/nlohmann/json/issues/408)
|
||||
- Heap-buffer-overflow \(OSS-Fuzz issue 343\) [\#407](https://github.com/nlohmann/json/issues/407)
|
||||
- Heap-buffer-overflow \(OSS-Fuzz issue 342\) [\#405](https://github.com/nlohmann/json/issues/405)
|
||||
- strerror throwing error in compiler VS2015 [\#403](https://github.com/nlohmann/json/issues/403)
|
||||
- json::parse of std::string being underlined by Visual Studio [\#402](https://github.com/nlohmann/json/issues/402)
|
||||
- Explicitly getting string without .dump\(\) [\#401](https://github.com/nlohmann/json/issues/401)
|
||||
@@ -1800,7 +1920,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Allow for forward declaring nlohmann::json [\#381](https://github.com/nlohmann/json/issues/381)
|
||||
- Bug in overflow detection when parsing integers [\#380](https://github.com/nlohmann/json/issues/380)
|
||||
- A unique name to mention the library? [\#377](https://github.com/nlohmann/json/issues/377)
|
||||
- Support for comments. [\#376](https://github.com/nlohmann/json/issues/376)
|
||||
- Non-unique keys in objects. [\#375](https://github.com/nlohmann/json/issues/375)
|
||||
- Request: binary serialization/deserialization [\#358](https://github.com/nlohmann/json/issues/358)
|
||||
|
||||
@@ -1824,7 +1943,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- json::parse on failed stream gets stuck [\#366](https://github.com/nlohmann/json/issues/366)
|
||||
- Performance improvements [\#365](https://github.com/nlohmann/json/issues/365)
|
||||
- 'to\_string' is not a member of 'std' [\#364](https://github.com/nlohmann/json/issues/364)
|
||||
- Optional comment support. [\#363](https://github.com/nlohmann/json/issues/363)
|
||||
- Crash in dump\(\) from a static object [\#359](https://github.com/nlohmann/json/issues/359)
|
||||
- json::parse\(...\) vs json j; j.parse\(...\) [\#357](https://github.com/nlohmann/json/issues/357)
|
||||
- Hi, is there any method to dump json to string with the insert order rather than alphabets [\#356](https://github.com/nlohmann/json/issues/356)
|
||||
@@ -1879,6 +1997,7 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Fix usage examples' comments for std::multiset [\#321](https://github.com/nlohmann/json/pull/321) ([vasild](https://github.com/vasild))
|
||||
- Include dir relocation [\#318](https://github.com/nlohmann/json/pull/318) ([ChristophJud](https://github.com/ChristophJud))
|
||||
- trivial documentation fix [\#313](https://github.com/nlohmann/json/pull/313) ([5tefan](https://github.com/5tefan))
|
||||
- unit-constructor1.cpp: Fix floating point truncation warning [\#300](https://github.com/nlohmann/json/pull/300) ([t-b](https://github.com/t-b))
|
||||
|
||||
## [v2.0.5](https://github.com/nlohmann/json/releases/tag/v2.0.5) (2016-09-14)
|
||||
|
||||
@@ -1902,7 +2021,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.2...v2.0.3)
|
||||
|
||||
- warning C4706: assignment within conditional expression [\#295](https://github.com/nlohmann/json/issues/295)
|
||||
- Strip comments / Minify [\#294](https://github.com/nlohmann/json/issues/294)
|
||||
- Q: Is it possible to build json tree from already UTF8 encoded values? [\#293](https://github.com/nlohmann/json/issues/293)
|
||||
- Equality operator results in array when assigned object [\#292](https://github.com/nlohmann/json/issues/292)
|
||||
- Support for integers not from the range \[-\(2\*\*53\)+1, \(2\*\*53\)-1\] in parser [\#291](https://github.com/nlohmann/json/issues/291)
|
||||
@@ -1912,8 +2030,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Incorrect parsing of large int64\_t numbers [\#287](https://github.com/nlohmann/json/issues/287)
|
||||
- \[question\]: macro to disable floating point support [\#284](https://github.com/nlohmann/json/issues/284)
|
||||
|
||||
- unit-constructor1.cpp: Fix floating point truncation warning [\#300](https://github.com/nlohmann/json/pull/300) ([t-b](https://github.com/t-b))
|
||||
|
||||
## [v2.0.2](https://github.com/nlohmann/json/releases/tag/v2.0.2) (2016-07-31)
|
||||
|
||||
[Full Changelog](https://github.com/nlohmann/json/compare/v2.0.1...v2.0.2)
|
||||
@@ -1990,7 +2106,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- What is within scope? [\#192](https://github.com/nlohmann/json/issues/192)
|
||||
- Bugs in miloyip/nativejson-benchmark: roundtrips [\#187](https://github.com/nlohmann/json/issues/187)
|
||||
- Floating point exceptions [\#181](https://github.com/nlohmann/json/issues/181)
|
||||
- Integer conversion to unsigned [\#178](https://github.com/nlohmann/json/issues/178)
|
||||
- map string string fails to compile [\#176](https://github.com/nlohmann/json/issues/176)
|
||||
- In basic\_json::basic\_json\(const CompatibleArrayType& val\), the requirement of CompatibleArrayType is not strict enough. [\#174](https://github.com/nlohmann/json/issues/174)
|
||||
- Provide a FAQ [\#163](https://github.com/nlohmann/json/issues/163)
|
||||
@@ -2009,7 +2124,6 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- fixed noexcept; added constexpr [\#208](https://github.com/nlohmann/json/pull/208) ([nlohmann](https://github.com/nlohmann))
|
||||
- Add support for afl-fuzz testing [\#207](https://github.com/nlohmann/json/pull/207) ([mykter](https://github.com/mykter))
|
||||
- replaced ssize\_t occurrences with auto \(addresses \#204\) [\#205](https://github.com/nlohmann/json/pull/205) ([nlohmann](https://github.com/nlohmann))
|
||||
- Fixed issue \#199 - Small bugs in json.hpp \(get\_number\) and unit.cpp \(non-standard integer type test\) [\#200](https://github.com/nlohmann/json/pull/200) ([twelsby](https://github.com/twelsby))
|
||||
- Fix broken link [\#197](https://github.com/nlohmann/json/pull/197) ([vog](https://github.com/vog))
|
||||
- Issue \#195 - update Travis to Trusty due to gcc/clang strtod\(\) bug [\#196](https://github.com/nlohmann/json/pull/196) ([twelsby](https://github.com/twelsby))
|
||||
- Issue \#178 - Extending support to full uint64\_t/int64\_t range and unsigned type \(updated\) [\#193](https://github.com/nlohmann/json/pull/193) ([twelsby](https://github.com/twelsby))
|
||||
@@ -2023,6 +2137,7 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- Floating point equality [\#185](https://github.com/nlohmann/json/issues/185)
|
||||
- Unused variables in catch [\#180](https://github.com/nlohmann/json/issues/180)
|
||||
- Typo in documentation [\#179](https://github.com/nlohmann/json/issues/179)
|
||||
- Integer conversion to unsigned [\#178](https://github.com/nlohmann/json/issues/178)
|
||||
- JSON performance benchmark comparision [\#177](https://github.com/nlohmann/json/issues/177)
|
||||
- Since re2c is often ignored in pull requests, it may make sense to make a contributing.md file [\#175](https://github.com/nlohmann/json/issues/175)
|
||||
- Question about exceptions [\#173](https://github.com/nlohmann/json/issues/173)
|
||||
@@ -2036,11 +2151,11 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- range based for loop for objects [\#83](https://github.com/nlohmann/json/issues/83)
|
||||
- Consider submitting this to the Boost Library Incubator [\#66](https://github.com/nlohmann/json/issues/66)
|
||||
|
||||
- Fixed issue \#199 - Small bugs in json.hpp \(get\_number\) and unit.cpp \(non-standard integer type test\) [\#200](https://github.com/nlohmann/json/pull/200) ([twelsby](https://github.com/twelsby))
|
||||
- Fixed Issue \#186 - add strto\(f|d|ld\) overload wrappers, "-0.0" special case and FP trailing zero [\#191](https://github.com/nlohmann/json/pull/191) ([twelsby](https://github.com/twelsby))
|
||||
- Issue \#185 - remove approx\(\) and use \#pragma to kill warnings [\#190](https://github.com/nlohmann/json/pull/190) ([twelsby](https://github.com/twelsby))
|
||||
- Fixed Issue \#171 - added two extra template overloads of operator\[\] for T\* arguments [\#189](https://github.com/nlohmann/json/pull/189) ([twelsby](https://github.com/twelsby))
|
||||
- Fixed issue \#167 - removed operator ValueType\(\) condition for VS2015 [\#188](https://github.com/nlohmann/json/pull/188) ([twelsby](https://github.com/twelsby))
|
||||
- Implementation of get\_ref\(\) [\#184](https://github.com/nlohmann/json/pull/184) ([dariomt](https://github.com/dariomt))
|
||||
- Fixed some typos in CONTRIBUTING.md [\#182](https://github.com/nlohmann/json/pull/182) ([nibroc](https://github.com/nibroc))
|
||||
|
||||
## [v1.0.0](https://github.com/nlohmann/json/releases/tag/v1.0.0) (2015-12-27)
|
||||
@@ -2077,12 +2192,12 @@ All notable changes to this project will be documented in this file. This projec
|
||||
- error: unterminated raw string [\#109](https://github.com/nlohmann/json/issues/109)
|
||||
- vector\<json\> copy constructor really weird [\#108](https://github.com/nlohmann/json/issues/108)
|
||||
- \[clang-3.6.2\] string/sstream with number to json issue [\#107](https://github.com/nlohmann/json/issues/107)
|
||||
- maintaining order of keys during iteration [\#106](https://github.com/nlohmann/json/issues/106)
|
||||
- object field accessors [\#103](https://github.com/nlohmann/json/issues/103)
|
||||
- v8pp and json [\#95](https://github.com/nlohmann/json/issues/95)
|
||||
- Wishlist [\#65](https://github.com/nlohmann/json/issues/65)
|
||||
- Windows/Visual Studio \(through 2013\) is unsupported [\#62](https://github.com/nlohmann/json/issues/62)
|
||||
|
||||
- Implementation of get\_ref\(\) [\#184](https://github.com/nlohmann/json/pull/184) ([dariomt](https://github.com/dariomt))
|
||||
- Replace sprintf with hex function, this fixes \#149 [\#153](https://github.com/nlohmann/json/pull/153) ([whackashoe](https://github.com/whackashoe))
|
||||
- Fix character skipping after a surrogate pair [\#146](https://github.com/nlohmann/json/pull/146) ([robertmrk](https://github.com/robertmrk))
|
||||
- Detect correctly pointer-to-const [\#137](https://github.com/nlohmann/json/pull/137) ([dariomt](https://github.com/dariomt))
|
||||
|
||||
126
Makefile
126
Makefile
@@ -5,7 +5,7 @@
|
||||
##########################################################################
|
||||
|
||||
# directory to recent compiler binaries
|
||||
COMPILER_DIR=/Users/niels/Documents/projects/compilers/local/bin
|
||||
COMPILER_DIR=/usr/local/opt/llvm/bin
|
||||
|
||||
# find GNU sed to use `-i` parameter
|
||||
SED:=$(shell command -v gsed || which sed)
|
||||
@@ -30,7 +30,6 @@ AMALGAMATED_FILE=single_include/nlohmann/json.hpp
|
||||
all:
|
||||
@echo "amalgamate - amalgamate file single_include/nlohmann/json.hpp from the include/nlohmann sources"
|
||||
@echo "ChangeLog.md - generate ChangeLog file"
|
||||
@echo "check - compile and execute test suite"
|
||||
@echo "check-amalgamation - check whether sources have been amalgamated"
|
||||
@echo "clean - remove built files"
|
||||
@echo "coverage - create coverage information with lcov"
|
||||
@@ -44,38 +43,24 @@ all:
|
||||
@echo "fuzz_testing_cbor - prepare fuzz testing of the CBOR parser"
|
||||
@echo "fuzz_testing_msgpack - prepare fuzz testing of the MessagePack parser"
|
||||
@echo "fuzz_testing_ubjson - prepare fuzz testing of the UBJSON parser"
|
||||
@echo "json_unit - create single-file test executable"
|
||||
@echo "pedantic_clang - run Clang with maximal warning flags"
|
||||
@echo "pedantic_gcc - run GCC with maximal warning flags"
|
||||
@echo "pretty - beautify code with Artistic Style"
|
||||
@echo "run_benchmarks - build and run benchmarks"
|
||||
|
||||
|
||||
##########################################################################
|
||||
# unit tests
|
||||
##########################################################################
|
||||
|
||||
# build unit tests
|
||||
json_unit:
|
||||
@$(MAKE) json_unit -C test
|
||||
|
||||
# run unit tests
|
||||
check:
|
||||
$(MAKE) check -C test
|
||||
|
||||
|
||||
##########################################################################
|
||||
# coverage
|
||||
##########################################################################
|
||||
|
||||
coverage:
|
||||
rm -fr build_coverage
|
||||
mkdir build_coverage
|
||||
cd build_coverage ; cmake .. -GNinja -DCMAKE_BUILD_TYPE=Debug -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON
|
||||
cd build_coverage ; ninja
|
||||
cd build_coverage ; ctest -j10
|
||||
cd build_coverage ; ninja lcov_html
|
||||
open build_coverage/test/html/index.html
|
||||
rm -fr cmake-build-coverage
|
||||
mkdir cmake-build-coverage
|
||||
cd cmake-build-coverage ; cmake .. -GNinja -DCMAKE_BUILD_TYPE=Debug -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON
|
||||
cd cmake-build-coverage ; ninja
|
||||
cd cmake-build-coverage ; ctest -j10
|
||||
cd cmake-build-coverage ; ninja lcov_html
|
||||
open cmake-build-coverage/test/html/index.html
|
||||
|
||||
##########################################################################
|
||||
# documentation tests
|
||||
@@ -96,13 +81,14 @@ doctest:
|
||||
# -Wno-documentation-unknown-command: code uses user-defined commands like @complexity
|
||||
# -Wno-exit-time-destructors: warning in json code triggered by NLOHMANN_JSON_SERIALIZE_ENUM
|
||||
# -Wno-float-equal: not all comparisons in the tests can be replaced by Approx
|
||||
# -Wno-keyword-macro: unit-tests use "#define private public"
|
||||
# -Wno-missing-prototypes: for NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE
|
||||
# -Wno-padded: padding is nothing to warn about
|
||||
# -Wno-range-loop-analysis: items tests "for(const auto i...)"
|
||||
# -Wno-extra-semi-stmt: spurious warnings for semicolons after JSON_ASSERT()
|
||||
# -Wno-switch-enum -Wno-covered-switch-default: pedantic/contradicting warnings about switches
|
||||
# -Wno-weak-vtables: exception class is defined inline, but has virtual method
|
||||
pedantic_clang:
|
||||
rm -fr build_pedantic
|
||||
rm -fr cmake-build-pedantic
|
||||
CXXFLAGS=" \
|
||||
-std=c++11 -Wno-c++98-compat -Wno-c++98-compat-pedantic \
|
||||
-Werror \
|
||||
@@ -112,16 +98,17 @@ pedantic_clang:
|
||||
-Wno-documentation-unknown-command \
|
||||
-Wno-exit-time-destructors \
|
||||
-Wno-float-equal \
|
||||
-Wno-keyword-macro \
|
||||
-Wno-missing-prototypes \
|
||||
-Wno-padded \
|
||||
-Wno-range-loop-analysis \
|
||||
-Wno-extra-semi-stmt \
|
||||
-Wno-switch-enum -Wno-covered-switch-default \
|
||||
-Wno-weak-vtables" cmake -S . -B build_pedantic -GNinja -DCMAKE_BUILD_TYPE=Debug -DJSON_MultipleHeaders=ON -DJSON_BuildTests=On
|
||||
cmake --build build_pedantic
|
||||
-Wno-weak-vtables" cmake -S . -B cmake-build-pedantic -GNinja -DCMAKE_BUILD_TYPE=Debug -DJSON_MultipleHeaders=ON -DJSON_BuildTests=On
|
||||
cmake --build cmake-build-pedantic
|
||||
|
||||
# calling GCC with most warnings
|
||||
pedantic_gcc:
|
||||
rm -fr build_pedantic
|
||||
rm -fr cmake-build-pedantic
|
||||
CXXFLAGS=" \
|
||||
-std=c++11 \
|
||||
-pedantic \
|
||||
@@ -253,7 +240,7 @@ pedantic_gcc:
|
||||
-Wmismatched-tags \
|
||||
-Wmissing-attributes \
|
||||
-Wmissing-braces \
|
||||
-Wmissing-declarations \
|
||||
-Wno-missing-declarations \
|
||||
-Wmissing-field-initializers \
|
||||
-Wmissing-include-dirs \
|
||||
-Wmissing-profile \
|
||||
@@ -379,19 +366,19 @@ pedantic_gcc:
|
||||
-Wwrite-strings \
|
||||
-Wzero-as-null-pointer-constant \
|
||||
-Wzero-length-bounds \
|
||||
" cmake -S . -B build_pedantic -GNinja -DCMAKE_BUILD_TYPE=Debug -DJSON_MultipleHeaders=ON -DJSON_BuildTests=On
|
||||
cmake --build build_pedantic
|
||||
" cmake -S . -B cmake-build-pedantic -GNinja -DCMAKE_BUILD_TYPE=Debug -DJSON_MultipleHeaders=ON -DJSON_BuildTests=On
|
||||
cmake --build cmake-build-pedantic
|
||||
|
||||
##########################################################################
|
||||
# benchmarks
|
||||
##########################################################################
|
||||
|
||||
run_benchmarks:
|
||||
rm -fr build_benchmarks
|
||||
mkdir build_benchmarks
|
||||
cd build_benchmarks ; cmake ../benchmarks -GNinja -DCMAKE_BUILD_TYPE=Release -DJSON_BuildTests=On
|
||||
cd build_benchmarks ; ninja
|
||||
cd build_benchmarks ; ./json_benchmarks
|
||||
rm -fr cmake-build-benchmarks
|
||||
mkdir cmake-build-benchmarks
|
||||
cd cmake-build-benchmarks ; cmake ../benchmarks -GNinja -DCMAKE_BUILD_TYPE=Release -DJSON_BuildTests=On
|
||||
cd cmake-build-benchmarks ; ninja
|
||||
cd cmake-build-benchmarks ; ./json_benchmarks
|
||||
|
||||
##########################################################################
|
||||
# fuzzing
|
||||
@@ -464,14 +451,14 @@ cppcheck:
|
||||
|
||||
# call Clang Static Analyzer <https://clang-analyzer.llvm.org>
|
||||
clang_analyze:
|
||||
rm -fr clang_analyze_build
|
||||
mkdir clang_analyze_build
|
||||
cd clang_analyze_build ; CCC_CXX=$(COMPILER_DIR)/clang++ CXX=$(COMPILER_DIR)/clang++ $(COMPILER_DIR)/scan-build cmake .. -GNinja -DJSON_BuildTests=On
|
||||
cd clang_analyze_build ; \
|
||||
rm -fr cmake-build-clang-analyze
|
||||
mkdir cmake-build-clang-analyze
|
||||
cd cmake-build-clang-analyze ; CCC_CXX=$(COMPILER_DIR)/clang++ CXX=$(COMPILER_DIR)/clang++ $(COMPILER_DIR)/scan-build cmake .. -GNinja -DJSON_BuildTests=On
|
||||
cd cmake-build-clang-analyze ; \
|
||||
$(COMPILER_DIR)/scan-build \
|
||||
-enable-checker alpha.core.BoolAssignment,alpha.core.CallAndMessageUnInitRefArg,alpha.core.CastSize,alpha.core.CastToStruct,alpha.core.Conversion,alpha.core.DynamicTypeChecker,alpha.core.FixedAddr,alpha.core.PointerArithm,alpha.core.PointerSub,alpha.core.SizeofPtr,alpha.core.StackAddressAsyncEscape,alpha.core.TestAfterDivZero,alpha.deadcode.UnreachableCode,core.builtin.BuiltinFunctions,core.builtin.NoReturnFunctions,core.CallAndMessage,core.DivideZero,core.DynamicTypePropagation,core.NonnilStringConstants,core.NonNullParamChecker,core.NullDereference,core.StackAddressEscape,core.UndefinedBinaryOperatorResult,core.uninitialized.ArraySubscript,core.uninitialized.Assign,core.uninitialized.Branch,core.uninitialized.CapturedBlockVariable,core.uninitialized.UndefReturn,core.VLASize,cplusplus.InnerPointer,cplusplus.Move,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,cplusplus.SelfAssignment,deadcode.DeadStores,nullability.NullableDereferenced,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull \
|
||||
--use-c++=$(COMPILER_DIR)/clang++ -analyze-headers -o report ninja
|
||||
open clang_analyze_build/report/*/index.html
|
||||
open cmake-build-clang-analyze/report/*/index.html
|
||||
|
||||
# call cpplint <https://github.com/cpplint/cpplint>
|
||||
# Note: some errors expected due to false positives
|
||||
@@ -482,22 +469,22 @@ cpplint:
|
||||
|
||||
# call Clang-Tidy <https://clang.llvm.org/extra/clang-tidy/>
|
||||
clang_tidy:
|
||||
$(COMPILER_DIR)/clang-tidy $(AMALGAMATED_FILE) -- -Iinclude -std=c++11
|
||||
$(COMPILER_DIR)/clang-tidy $(SRCS) -- -Iinclude -std=c++11
|
||||
|
||||
# call PVS-Studio Analyzer <https://www.viva64.com/en/pvs-studio/>
|
||||
pvs_studio:
|
||||
rm -fr pvs_studio_build
|
||||
mkdir pvs_studio_build
|
||||
cd pvs_studio_build ; cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=On
|
||||
cd pvs_studio_build ; pvs-studio-analyzer analyze -j 10
|
||||
cd pvs_studio_build ; plog-converter -a'GA:1,2;64:1;CS' -t fullhtml PVS-Studio.log -o pvs
|
||||
open pvs_studio_build/pvs/index.html
|
||||
rm -fr cmake-build-pvs-studio
|
||||
mkdir cmake-build-pvs-studio
|
||||
cd cmake-build-pvs-studio ; cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DJSON_MultipleHeaders=ON
|
||||
cd cmake-build-pvs-studio ; pvs-studio-analyzer analyze -j 10
|
||||
cd cmake-build-pvs-studio ; plog-converter -a'GA:1,2;64:1;CS' -t fullhtml PVS-Studio.log -o pvs
|
||||
open cmake-build-pvs-studio/pvs/index.html
|
||||
|
||||
# call Infer <https://fbinfer.com> static analyzer
|
||||
infer:
|
||||
rm -fr infer_build
|
||||
mkdir infer_build
|
||||
cd infer_build ; infer compile -- cmake .. ; infer run -- make -j 4
|
||||
rm -fr cmake-build-infer
|
||||
mkdir cmake-build-infer
|
||||
cd cmake-build-infer ; infer compile -- cmake .. -DJSON_MultipleHeaders=ON ; infer run -- make -j 4
|
||||
|
||||
# call OCLint <http://oclint.org> static analyzer
|
||||
oclint:
|
||||
@@ -506,11 +493,11 @@ oclint:
|
||||
|
||||
# execute the test suite with Clang sanitizers (address and undefined behavior)
|
||||
clang_sanitize:
|
||||
rm -fr clang_sanitize_build
|
||||
mkdir clang_sanitize_build
|
||||
cd clang_sanitize_build ; CXX=$(COMPILER_DIR)/clang++ cmake .. -DJSON_Sanitizer=On -DJSON_MultipleHeaders=ON -DJSON_BuildTests=On -GNinja
|
||||
cd clang_sanitize_build ; ninja
|
||||
cd clang_sanitize_build ; ctest -j10
|
||||
rm -fr cmake-build-clang-sanitize
|
||||
mkdir cmake-build-clang-sanitize
|
||||
cd cmake-build-clang-sanitize ; CXX=$(COMPILER_DIR)/clang++ cmake .. -DJSON_Sanitizer=On -DJSON_MultipleHeaders=ON -DJSON_BuildTests=On -GNinja
|
||||
cd cmake-build-clang-sanitize ; ninja
|
||||
cd cmake-build-clang-sanitize ; ctest -j10
|
||||
|
||||
|
||||
##########################################################################
|
||||
@@ -538,7 +525,11 @@ pretty:
|
||||
--preserve-date \
|
||||
--suffix=none \
|
||||
--formatted \
|
||||
$(SRCS) $(AMALGAMATED_FILE) test/src/*.cpp benchmarks/src/benchmarks.cpp doc/examples/*.cpp
|
||||
$(SRCS) $(AMALGAMATED_FILE) test/src/*.cpp test/src/*.hpp benchmarks/src/benchmarks.cpp doc/examples/*.cpp
|
||||
|
||||
# call the Clang-Format on all source files
|
||||
pretty_format:
|
||||
for FILE in $(SRCS) $(AMALGAMATED_FILE) test/src/*.cpp test/src/*.hpp benchmarks/src/benchmarks.cpp doc/examples/*.cpp; do echo $$FILE; clang-format -i $$FILE; done
|
||||
|
||||
# create single header file
|
||||
amalgamate: $(AMALGAMATED_FILE)
|
||||
@@ -560,7 +551,7 @@ check-amalgamation:
|
||||
check-single-includes:
|
||||
@for x in $(SRCS); do \
|
||||
echo "Checking self-sufficiency of $$x..." ; \
|
||||
echo "#include <$$x>\nint main() {}\n" | sed 's|include/||' > single_include_test.cpp; \
|
||||
echo "#include <$$x>\nint main() {}\n" | $(SED) 's|include/||' > single_include_test.cpp; \
|
||||
$(CXX) $(CXXFLAGS) -Iinclude -std=c++11 single_include_test.cpp -o single_include_test; \
|
||||
rm -f single_include_test.cpp single_include_test; \
|
||||
done
|
||||
@@ -570,17 +561,17 @@ check-single-includes:
|
||||
# CMake
|
||||
##########################################################################
|
||||
|
||||
# grep "^option" CMakeLists.txt test/CMakeLists.txt | sed 's/(/ /' | awk '{print $2}' | xargs
|
||||
# grep "^option" CMakeLists.txt test/CMakeLists.txt | $(SED) 's/(/ /' | awk '{print $2}' | xargs
|
||||
|
||||
# check if all flags of our CMake files work
|
||||
check_cmake_flags_do:
|
||||
$(CMAKE_BINARY) --version
|
||||
for flag in '' JSON_BuildTests JSON_Install JSON_MultipleHeaders JSON_Sanitizer JSON_Valgrind JSON_NoExceptions JSON_Coverage; do \
|
||||
for flag in JSON_BuildTests JSON_Install JSON_MultipleHeaders JSON_Sanitizer JSON_Valgrind JSON_NoExceptions JSON_Coverage; do \
|
||||
rm -fr cmake_build; \
|
||||
mkdir cmake_build; \
|
||||
echo "$(CMAKE_BINARY) .. -D$$flag=On" ; \
|
||||
echo "\n\n$(CMAKE_BINARY) .. -D$$flag=On\n" ; \
|
||||
cd cmake_build ; \
|
||||
CXX=g++-8 $(CMAKE_BINARY) .. -D$$flag=On -DCMAKE_CXX_COMPILE_FEATURES="cxx_std_11;cxx_range_for" -DCMAKE_CXX_FLAGS="-std=gnu++11" ; \
|
||||
$(CMAKE_BINARY) -Werror=dev .. -D$$flag=On -DCMAKE_CXX_COMPILE_FEATURES="cxx_std_11;cxx_range_for" -DCMAKE_CXX_FLAGS="-std=gnu++11" ; \
|
||||
test -f Makefile || exit 1 ; \
|
||||
cd .. ; \
|
||||
done;
|
||||
@@ -619,7 +610,7 @@ ChangeLog.md:
|
||||
release:
|
||||
rm -fr release_files
|
||||
mkdir release_files
|
||||
zip -9 --recurse-paths -X include.zip $(SRCS) $(AMALGAMATED_FILE) meson.build
|
||||
zip -9 --recurse-paths -X include.zip $(SRCS) $(AMALGAMATED_FILE) meson.build LICENSE.MIT
|
||||
gpg --armor --detach-sig include.zip
|
||||
mv include.zip include.zip.asc release_files
|
||||
gpg --armor --detach-sig $(AMALGAMATED_FILE)
|
||||
@@ -638,9 +629,8 @@ clean:
|
||||
rm -fr json_unit json_benchmarks fuzz fuzz-testing *.dSYM test/*.dSYM oclint_report.html
|
||||
rm -fr benchmarks/files/numbers/*.json
|
||||
rm -fr cmake-3.1.0-Darwin64.tar.gz cmake-3.1.0-Darwin64
|
||||
rm -fr build_coverage build_benchmarks fuzz-testing clang_analyze_build pvs_studio_build infer_build clang_sanitize_build cmake_build
|
||||
rm -fr cmake-build-coverage cmake-build-benchmarks cmake-build-pedantic fuzz-testing cmake-build-clang-analyze cmake-build-pvs-studio cmake-build-infer cmake-build-clang-sanitize cmake_build
|
||||
$(MAKE) clean -Cdoc
|
||||
$(MAKE) clean -Ctest
|
||||
|
||||
##########################################################################
|
||||
# Thirdparty code
|
||||
@@ -649,6 +639,6 @@ clean:
|
||||
update_hedley:
|
||||
rm -f include/nlohmann/thirdparty/hedley/hedley.hpp include/nlohmann/thirdparty/hedley/hedley_undef.hpp
|
||||
curl https://raw.githubusercontent.com/nemequ/hedley/master/hedley.h -o include/nlohmann/thirdparty/hedley/hedley.hpp
|
||||
gsed -i 's/HEDLEY_/JSON_HEDLEY_/g' include/nlohmann/thirdparty/hedley/hedley.hpp
|
||||
grep "[[:blank:]]*#[[:blank:]]*undef" include/nlohmann/thirdparty/hedley/hedley.hpp | grep -v "__" | sort | uniq | gsed 's/ //g' | gsed 's/undef/undef /g' > include/nlohmann/thirdparty/hedley/hedley_undef.hpp
|
||||
$(SED) -i 's/HEDLEY_/JSON_HEDLEY_/g' include/nlohmann/thirdparty/hedley/hedley.hpp
|
||||
grep "[[:blank:]]*#[[:blank:]]*undef" include/nlohmann/thirdparty/hedley/hedley.hpp | grep -v "__" | sort | uniq | $(SED) 's/ //g' | $(SED) 's/undef/undef /g' > include/nlohmann/thirdparty/hedley/hedley_undef.hpp
|
||||
$(MAKE) amalgamate
|
||||
|
||||
133
README.md
133
README.md
@@ -14,7 +14,6 @@
|
||||
[](https://wandbox.org/permlink/3lCHrFUZANONKv7a)
|
||||
[](https://nlohmann.github.io/json/doxygen/index.html)
|
||||
[](https://raw.githubusercontent.com/nlohmann/json/master/LICENSE.MIT)
|
||||
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fnlohmann%2Fjson?ref=badge_shield)
|
||||
[](https://github.com/nlohmann/json/releases)
|
||||
[](https://github.com/nlohmann/json/releases)
|
||||
[](https://github.com/nlohmann/json/issues)
|
||||
@@ -27,6 +26,7 @@
|
||||
- [Integration](#integration)
|
||||
- [CMake](#cmake)
|
||||
- [Package Managers](#package-managers)
|
||||
- [Pkg-config](#pkg-config)
|
||||
- [Examples](#examples)
|
||||
- [JSON as first-class data type](#json-as-first-class-data-type)
|
||||
- [Serialization / Deserialization](#serialization--deserialization)
|
||||
@@ -75,6 +75,7 @@ You can sponsor this library at [GitHub Sponsors](https://github.com/sponsors/nl
|
||||
- [Michael Hartmann](https://github.com/reFX-Mike)
|
||||
- [Stefan Hagen](https://github.com/sthagen)
|
||||
- [Steve Sperandeo](https://github.com/homer6)
|
||||
- [Robert Jefe Lindstädt](https://github.com/eljefedelrodeodeljefe)
|
||||
|
||||
Thanks everyone!
|
||||
|
||||
@@ -230,9 +231,32 @@ Please file issues [here](https://github.com/build2-packaging/nlohmann-json) if
|
||||
|
||||
If you are using [`wsjcpp`](https://wsjcpp.org), you can use the command `wsjcpp install "https://github.com/nlohmann/json:develop"` to get the latest version. Note you can change the branch ":develop" to an existing tag or another branch.
|
||||
|
||||
If you are using [`CPM.cmake`](https://github.com/TheLartians/CPM.cmake), you can check this [`example`](https://github.com/TheLartians/CPM.cmake/tree/master/examples/json). After [adding CPM script](https://github.com/TheLartians/CPM.cmake#adding-cpm) to your project, implement the following snippet to your CMake:
|
||||
|
||||
```cmake
|
||||
CPMAddPackage(
|
||||
NAME nlohmann_json
|
||||
GITHUB_REPOSITORY nlohmann/json
|
||||
VERSION 3.9.1)
|
||||
```
|
||||
|
||||
### Pkg-config
|
||||
|
||||
If you are using bare Makefiles, you can use `pkg-config` to generate the include flags that point to where the library is installed:
|
||||
|
||||
```sh
|
||||
pkg-config nlohmann_json --cflags
|
||||
```
|
||||
|
||||
Users of the Meson build system will also be able to use a system wide library, which will be found by `pkg-config`:
|
||||
|
||||
```meson
|
||||
json = dependency('nlohmann_json', required: true)
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
Beside the examples below, you may want to check the [documentation](https://nlohmann.github.io/json/) where each function contains a separate code example (e.g., check out [`emplace()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a5338e282d1d02bed389d852dd670d98d.html#a5338e282d1d02bed389d852dd670d98d)). All [example files](https://github.com/nlohmann/json/tree/develop/doc/examples) can be compiled and executed on their own (e.g., file [emplace.cpp](https://github.com/nlohmann/json/blob/develop/doc/examples/emplace.cpp)).
|
||||
Beside the examples below, you may want to check the [documentation](https://nlohmann.github.io/json/) where each function contains a separate code example (e.g., check out [`emplace()`](https://nlohmann.github.io/json/api/basic_json/emplace/)). All [example files](https://github.com/nlohmann/json/tree/develop/doc/examples) can be compiled and executed on their own (e.g., file [emplace.cpp](https://github.com/nlohmann/json/blob/develop/doc/examples/emplace.cpp)).
|
||||
|
||||
### JSON as first-class data type
|
||||
|
||||
@@ -301,7 +325,7 @@ json j2 = {
|
||||
};
|
||||
```
|
||||
|
||||
Note that in all these cases, you never need to "tell" the compiler which JSON value type you want to use. If you want to be explicit or express some edge cases, the functions [`json::array()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a9ad7ec0bc1082ed09d10900fbb20a21f.html#a9ad7ec0bc1082ed09d10900fbb20a21f) and [`json::object()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_aaf509a7c029100d292187068f61c99b8.html#aaf509a7c029100d292187068f61c99b8) will help:
|
||||
Note that in all these cases, you never need to "tell" the compiler which JSON value type you want to use. If you want to be explicit or express some edge cases, the functions [`json::array()`](https://nlohmann.github.io/json/api/basic_json/array/) and [`json::object()`](https://nlohmann.github.io/json/api/basic_json/object/) will help:
|
||||
|
||||
```cpp
|
||||
// a way to express the empty array []
|
||||
@@ -336,7 +360,7 @@ auto j2 = R"(
|
||||
|
||||
Note that without appending the `_json` suffix, the passed string literal is not parsed, but just used as JSON string value. That is, `json j = "{ \"happy\": true, \"pi\": 3.141 }"` would just store the string `"{ "happy": true, "pi": 3.141 }"` rather than parsing the actual object.
|
||||
|
||||
The above example can also be expressed explicitly using [`json::parse()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a265a473e939184aa42655c9ccdf34e58.html#a265a473e939184aa42655c9ccdf34e58):
|
||||
The above example can also be expressed explicitly using [`json::parse()`](https://nlohmann.github.io/json/api/basic_json/parse/):
|
||||
|
||||
```cpp
|
||||
// parse explicitly
|
||||
@@ -379,9 +403,9 @@ std::cout << cpp_string << " == " << cpp_string2 << " == " << j_string.get<std::
|
||||
std::cout << j_string << " == " << serialized_string << std::endl;
|
||||
```
|
||||
|
||||
[`.dump()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a50ec80b02d0f3f51130d4abb5d1cfdc5.html#a50ec80b02d0f3f51130d4abb5d1cfdc5) always returns the serialized value, and [`.get<std::string>()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_aa6602bb24022183ab989439e19345d08.html#aa6602bb24022183ab989439e19345d08) returns the originally stored string value.
|
||||
[`.dump()`](https://nlohmann.github.io/json/api/basic_json/dump/) returns the originally stored string value.
|
||||
|
||||
Note the library only supports UTF-8. When you store strings with different encodings in the library, calling [`dump()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a50ec80b02d0f3f51130d4abb5d1cfdc5.html#a50ec80b02d0f3f51130d4abb5d1cfdc5) may throw an exception unless `json::error_handler_t::replace` or `json::error_handler_t::ignore` are used as error handlers.
|
||||
Note the library only supports UTF-8. When you store strings with different encodings in the library, calling [`dump()`](https://nlohmann.github.io/json/api/basic_json/dump/) may throw an exception unless `json::error_handler_t::replace` or `json::error_handler_t::ignore` are used as error handlers.
|
||||
|
||||
#### To/from streams (e.g. files, string streams)
|
||||
|
||||
@@ -468,7 +492,7 @@ MyIterator begin(MyContainer& tgt) {
|
||||
}
|
||||
|
||||
MyIterator end(const MyContainer&) {
|
||||
return {};
|
||||
return {};
|
||||
}
|
||||
|
||||
void foo() {
|
||||
@@ -497,6 +521,8 @@ bool number_float(number_float_t val, const string_t& s);
|
||||
|
||||
// called when a string is parsed; value is passed and can be safely moved away
|
||||
bool string(string_t& val);
|
||||
// called when a binary value is parsed; value is passed and can be safely moved away
|
||||
bool binary(binary_t& val);
|
||||
|
||||
// called when an object or array begins or ends, resp. The number of elements is passed (or -1 if not known)
|
||||
bool start_object(std::size_t elements);
|
||||
@@ -746,7 +772,8 @@ j_document.merge_patch(j_patch);
|
||||
Supported types can be implicitly converted to JSON values.
|
||||
|
||||
It is recommended to **NOT USE** implicit conversions **FROM** a JSON value.
|
||||
You can find more details about this recommendation [here](https://www.github.com/nlohmann/json/issues/958).
|
||||
You can find more details about this recommendation [here](https://www.github.com/nlohmann/json/issues/958).
|
||||
You can switch off implicit conversions by defining `JSON_USE_IMPLICIT_CONVERSIONS` to `0` before including the `json.hpp` header. When using CMake, you can also achieve this by setting the option `JSON_ImplicitConversions` to `OFF`.
|
||||
|
||||
```cpp
|
||||
// strings
|
||||
@@ -866,9 +893,45 @@ Some important things:
|
||||
* Those methods **MUST** be in your type's namespace (which can be the global namespace), or the library will not be able to locate them (in this example, they are in namespace `ns`, where `person` is defined).
|
||||
* Those methods **MUST** be available (e.g., proper headers must be included) everywhere you use these conversions. Look at [issue 1108](https://github.com/nlohmann/json/issues/1108) for errors that may occur otherwise.
|
||||
* When using `get<your_type>()`, `your_type` **MUST** be [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). (There is a way to bypass this requirement described later.)
|
||||
* In function `from_json`, use function [`at()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a93403e803947b86f4da2d1fb3345cf2c.html#a93403e803947b86f4da2d1fb3345cf2c) to access the object values rather than `operator[]`. In case a key does not exist, `at` throws an exception that you can handle, whereas `operator[]` exhibits undefined behavior.
|
||||
* In function `from_json`, use function [`at()`](https://nlohmann.github.io/json/api/basic_json/at/) to access the object values rather than `operator[]`. In case a key does not exist, `at` throws an exception that you can handle, whereas `operator[]` exhibits undefined behavior.
|
||||
* You do not need to add serializers or deserializers for STL types like `std::vector`: the library already implements these.
|
||||
|
||||
#### Simplify your life with macros
|
||||
|
||||
If you just want to serialize/deserialize some structs, the `to_json`/`from_json` functions can be a lot of boilerplate.
|
||||
|
||||
There are two macros to make your life easier as long as you (1) want to use a JSON object as serialization and (2) want to use the member variable names as object keys in that object:
|
||||
|
||||
- `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(name, member1, member2, ...)` is to be defined inside of the namespace of the class/struct to create code for.
|
||||
- `NLOHMANN_DEFINE_TYPE_INTRUSIVE(name, member1, member2, ...)` is to be defined inside of the class/struct to create code for. This macro can also access private members.
|
||||
|
||||
In both macros, the first parameter is the name of the class/struct, and all remaining parameters name the members.
|
||||
|
||||
##### Examples
|
||||
|
||||
The `to_json`/`from_json` functions for the `person` struct above can be created with:
|
||||
|
||||
```cpp
|
||||
namespace ns {
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(person, name, address, age)
|
||||
}
|
||||
```
|
||||
|
||||
Here is an example with private members, where `NLOHMANN_DEFINE_TYPE_INTRUSIVE` is needed:
|
||||
|
||||
```cpp
|
||||
namespace ns {
|
||||
class address {
|
||||
private:
|
||||
std::string street;
|
||||
int housenumber;
|
||||
int postcode;
|
||||
|
||||
public:
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(address, street, housenumber, postcode)
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
#### How do I convert third-party types?
|
||||
|
||||
@@ -1139,6 +1202,7 @@ Though it's 2020 already, the support for C++11 is still a bit sparse. Currently
|
||||
|
||||
- GCC 4.8 - 10.1 (and possibly later)
|
||||
- Clang 3.4 - 10.0 (and possibly later)
|
||||
- Apple Clang 9.1 - 12.0 (and possibly later)
|
||||
- Intel C++ Compiler 17.0.2 (and possibly later)
|
||||
- Microsoft Visual C++ 2015 / Build Tools 14.0.25123.0 (and possibly later)
|
||||
- Microsoft Visual C++ 2017 / Build Tools 15.5.180.51428 (and possibly later)
|
||||
@@ -1167,13 +1231,10 @@ The following compilers are currently used in continuous integration at [Travis]
|
||||
|
||||
| Compiler | Operating System | CI Provider |
|
||||
|-----------------------------------------------------------------|--------------------|----------------|
|
||||
| Apple Clang 9.1.0 (clang-902.0.39.1); Xcode 9.3 | macOS 10.13.3 | Travis |
|
||||
| Apple Clang 9.1.0 (clang-902.0.39.2); Xcode 9.4.1 | macOS 10.13.6 | Travis |
|
||||
| Apple Clang 10.0.0 (clang-1000.11.45.2); Xcode 10.0 | macOS 10.13.6 | Travis |
|
||||
| Apple Clang 10.0.0 (clang-1000.11.45.5); Xcode 10.1 | macOS 10.13.6 | Travis |
|
||||
| Apple Clang 10.0.1 (clang-1001.0.46.4); Xcode 10.2.1 | macOS 10.14.4 | Travis |
|
||||
| Apple Clang 11.0.0 (clang-1100.0.33.12); Xcode 11.2.1 | macOS 10.14.6 | Travis |
|
||||
| Apple Clang 11.0.3 (clang-1103.0.32.59); Xcode 11.4.1 | macOS 10.15.4 | GitHub Actions |
|
||||
| Apple Clang 12.0.0 (clang-1200.0.22.7); Xcode 11.4.1 | macOS 10.15.5 | Travis |
|
||||
| Clang 3.5.0 (3.5.0-4ubuntu2~trusty2) | Ubuntu 14.04.5 LTS | Travis |
|
||||
| Clang 3.6.2 (3.6.2-svn240577-1~exp1) | Ubuntu 14.04.5 LTS | Travis |
|
||||
| Clang 3.7.1 (3.7.1-svn253571-1~exp1) | Ubuntu 14.04.5 LTS | Travis |
|
||||
@@ -1184,6 +1245,8 @@ The following compilers are currently used in continuous integration at [Travis]
|
||||
| Clang 6.0.1 (6.0.1-svn334776-1~exp1~20190309042707.121) | Ubuntu 14.04.5 LTS | Travis |
|
||||
| Clang 7.1.0 (7.1.0-svn353565-1~exp1~20190419134007.64) | Ubuntu 14.04.5 LTS | Travis |
|
||||
| Clang 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) | Ubuntu 18.04.4 LTS | Travis |
|
||||
| Clang 9.0.0 (x86_64-pc-windows-msvc) | Windows-10.0.17763 | GitHub Actions |
|
||||
| Clang 10.0.0 (x86_64-pc-windows-msvc) | Windows-10.0.17763 | GitHub Actions |
|
||||
| GCC 4.8.5 (Ubuntu 4.8.5-4ubuntu8~14.04.2) | Ubuntu 14.04.5 LTS | Travis |
|
||||
| GCC 4.9.4 (Ubuntu 4.9.4-2ubuntu1~14.04.1) | Ubuntu 14.04.5 LTS | Travis |
|
||||
| GCC 5.5.0 (Ubuntu 5.5.0-12ubuntu1~14.04) | Ubuntu 14.04.5 LTS | Travis |
|
||||
@@ -1199,6 +1262,7 @@ The following compilers are currently used in continuous integration at [Travis]
|
||||
| MSVC 19.16.27035.0 (15.9.21+g9802d43bc3 for .NET Framework) | Windows-10.0.14393 | AppVeyor |
|
||||
| MSVC 19.25.28614.0 (Build Engine version 16.5.0+d4cbfca49 for .NET Framework) | Windows-10.0.17763 | AppVeyor |
|
||||
| MSVC 19.25.28614.0 (Build Engine version 16.5.0+d4cbfca49 for .NET Framework) | Windows-10.0.17763 | GitHub Actions |
|
||||
| MSVC 19.25.28614.0 (Build Engine version 16.5.0+d4cbfca49 for .NET Framework) with ClangCL 10.0.0 | Windows-10.0.17763 | GitHub Actions |
|
||||
|
||||
## License
|
||||
|
||||
@@ -1452,6 +1516,17 @@ I deeply appreciate the help of the following people.
|
||||
- [XyFreak](https://github.com/XyFreak) fixed a compiler warning.
|
||||
- [TotalCaesar659](https://github.com/TotalCaesar659) fixed links in the README.
|
||||
- [Tanuj Garg](https://github.com/tanuj208) improved the fuzzer coverage for UBSAN input.
|
||||
- [AODQ](https://github.com/AODQ) fixed a compiler warning.
|
||||
- [jwittbrodt](https://github.com/jwittbrodt) made `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE` inline.
|
||||
- [pfeatherstone](https://github.com/pfeatherstone) improved the upper bound of arguments of the `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE`/`NLOHMANN_DEFINE_TYPE_INTRUSIVE` macros.
|
||||
- [Jan Procházka](https://github.com/jprochazk) fixed a bug in the CBOR parser for binary and string values.
|
||||
- [T0b1-iOS](https://github.com/T0b1-iOS) fixed a bug in the new hash implementation.
|
||||
- [Matthew Bauer](https://github.com/matthewbauer) adjusted the CBOR writer to create tags for binary subtypes.
|
||||
- [gatopeich](https://github.com/gatopeich) implemented an ordered map container for `nlohmann::ordered_json`.
|
||||
- [Érico Nogueira Rolim](https://github.com/ericonr) added support for pkg-config.
|
||||
- [KonanM](https://github.com/KonanM) proposed an implementation for the `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE`/`NLOHMANN_DEFINE_TYPE_INTRUSIVE` macros.
|
||||
- [Guillaume Racicot](https://github.com/gracicot) implemented `string_view` support and allowed C++20 support.
|
||||
- [Alex Reinking](https://github.com/alexreinking) improved CMake support for `FetchContent`.
|
||||
|
||||
Thanks a lot for helping out! Please [let me know](mailto:mail@nlohmann.me) if I forgot someone.
|
||||
|
||||
@@ -1504,46 +1579,44 @@ The library supports **Unicode input** as follows:
|
||||
- [Unicode noncharacters](https://www.unicode.org/faq/private_use.html#nonchar1) will not be replaced by the library.
|
||||
- Invalid surrogates (e.g., incomplete pairs such as `\uDEAD`) will yield parse errors.
|
||||
- The strings stored in the library are UTF-8 encoded. When using the default string type (`std::string`), note that its length/size functions return the number of stored bytes rather than the number of characters or glyphs.
|
||||
- When you store strings with different encodings in the library, calling [`dump()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a50ec80b02d0f3f51130d4abb5d1cfdc5.html#a50ec80b02d0f3f51130d4abb5d1cfdc5) may throw an exception unless `json::error_handler_t::replace` or `json::error_handler_t::ignore` are used as error handlers.
|
||||
- When you store strings with different encodings in the library, calling [`dump()`](https://nlohmann.github.io/json/api/basic_json/dump/) may throw an exception unless `json::error_handler_t::replace` or `json::error_handler_t::ignore` are used as error handlers.
|
||||
|
||||
### Comments in JSON
|
||||
|
||||
This library does not support comments. It does so for three reasons:
|
||||
This library does not support comments by default. It does so for three reasons:
|
||||
|
||||
1. Comments are not part of the [JSON specification](https://tools.ietf.org/html/rfc8259). You may argue that `//` or `/* */` are allowed in JavaScript, but JSON is not JavaScript.
|
||||
2. This was not an oversight: Douglas Crockford [wrote on this](https://plus.google.com/118095276221607585885/posts/RK8qyGVaGSr) in May 2012:
|
||||
|
||||
> I removed comments from JSON because I saw people were using them to hold parsing directives, a practice which would have destroyed interoperability. I know that the lack of comments makes some people sad, but it shouldn't.
|
||||
> I removed comments from JSON because I saw people were using them to hold parsing directives, a practice which would have destroyed interoperability. I know that the lack of comments makes some people sad, but it shouldn't.
|
||||
|
||||
> Suppose you are using JSON to keep configuration files, which you would like to annotate. Go ahead and insert all the comments you like. Then pipe it through JSMin before handing it to your JSON parser.
|
||||
|
||||
3. It is dangerous for interoperability if some libraries would add comment support while others don't. Please check [The Harmful Consequences of the Robustness Principle](https://tools.ietf.org/html/draft-iab-protocol-maintenance-01) on this.
|
||||
|
||||
This library will not support comments in the future. If you wish to use comments, I see three options:
|
||||
|
||||
1. Strip comments before using this library.
|
||||
2. Use a different JSON library with comment support.
|
||||
3. Use a format that natively supports comments (e.g., YAML or JSON5).
|
||||
However, you can pass set parameter `ignore_comments` to true in the `parse` function to ignore `//` or `/* */` comments. Comments will then be treated as whitespace.
|
||||
|
||||
### Order of object keys
|
||||
|
||||
By default, the library does not preserve the **insertion order of object elements**. This is standards-compliant, as the [JSON standard](https://tools.ietf.org/html/rfc8259.html) defines objects as "an unordered collection of zero or more name/value pairs". If you do want to preserve the insertion order, you can specialize the object type with containers like [`tsl::ordered_map`](https://github.com/Tessil/ordered-map) ([integration](https://github.com/nlohmann/json/issues/546#issuecomment-304447518)) or [`nlohmann::fifo_map`](https://github.com/nlohmann/fifo_map) ([integration](https://github.com/nlohmann/json/issues/485#issuecomment-333652309)).
|
||||
By default, the library does not preserve the **insertion order of object elements**. This is standards-compliant, as the [JSON standard](https://tools.ietf.org/html/rfc8259.html) defines objects as "an unordered collection of zero or more name/value pairs".
|
||||
|
||||
If you do want to preserve the insertion order, you can try the type [`nlohmann::ordered_json`](https://github.com/nlohmann/json/issues/2179). Alternatively, you can use a more sophisticated ordered map like [`tsl::ordered_map`](https://github.com/Tessil/ordered-map) ([integration](https://github.com/nlohmann/json/issues/546#issuecomment-304447518)) or [`nlohmann::fifo_map`](https://github.com/nlohmann/fifo_map) ([integration](https://github.com/nlohmann/json/issues/485#issuecomment-333652309)).
|
||||
|
||||
### Memory Release
|
||||
|
||||
We checked with Valgrind and the Address Sanitizer (ASAN) that there are no memory leaks.
|
||||
We checked with Valgrind and the Address Sanitizer (ASAN) that there are no memory leaks.
|
||||
|
||||
If you find that a parsing program with this library does not release memory, please consider the following case and it maybe unrelated to this library.
|
||||
If you find that a parsing program with this library does not release memory, please consider the following case and it maybe unrelated to this library.
|
||||
|
||||
**Your program is compiled with glibc.** There is a tunable threshold that glibc uses to decide whether to actually return memory to the system or whether to cache it for later reuse. If in your program you make lots of small allocations and those small allocations are not a contiguous block and are presumably below the threshold, then they will not get returned to the OS.
|
||||
Here is a related issue [#1924](https://github.com/nlohmann/json/issues/1924).
|
||||
|
||||
### Further notes
|
||||
|
||||
- The code contains numerous debug **assertions** which can be switched off by defining the preprocessor macro `NDEBUG`, see the [documentation of `assert`](https://en.cppreference.com/w/cpp/error/assert). In particular, note [`operator[]`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a233b02b0839ef798942dd46157cc0fe6.html#a233b02b0839ef798942dd46157cc0fe6) implements **unchecked access** for const objects: If the given key is not present, the behavior is undefined (think of a dereferenced null pointer) and yields an [assertion failure](https://github.com/nlohmann/json/issues/289) if assertions are switched on. If you are not sure whether an element in an object exists, use checked access with the [`at()` function](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a73ae333487310e3302135189ce8ff5d8.html#a73ae333487310e3302135189ce8ff5d8).
|
||||
- The code contains numerous debug **assertions** which can be switched off by defining the preprocessor macro `NDEBUG`, see the [documentation of `assert`](https://en.cppreference.com/w/cpp/error/assert). In particular, note [`operator[]`](https://nlohmann.github.io/json/api/basic_json/operator%5B%5D/) implements **unchecked access** for const objects: If the given key is not present, the behavior is undefined (think of a dereferenced null pointer) and yields an [assertion failure](https://github.com/nlohmann/json/issues/289) if assertions are switched on. If you are not sure whether an element in an object exists, use checked access with the [`at()` function](https://nlohmann.github.io/json/api/basic_json/at/). Furthermore, you can define `JSON_ASSERT(x)` to replace calls to `assert(x)`.
|
||||
- As the exact type of a number is not defined in the [JSON specification](https://tools.ietf.org/html/rfc8259.html), this library tries to choose the best fitting C++ number type automatically. As a result, the type `double` may be used to store numbers which may yield [**floating-point exceptions**](https://github.com/nlohmann/json/issues/181) in certain rare situations if floating-point exceptions have been unmasked in the calling code. These exceptions are not caused by the library and need to be fixed in the calling code, such as by re-masking the exceptions prior to calling library functions.
|
||||
- The code can be compiled without C++ **runtime type identification** features; that is, you can use the `-fno-rtti` compiler flag.
|
||||
- **Exceptions** are used widely within the library. They can, however, be switched off with either using the compiler flag `-fno-exceptions` or by defining the symbol `JSON_NOEXCEPTION`. In this case, exceptions are replaced by `abort()` calls. You can further control this behavior by defining `JSON_THROW_USER´` (overriding `throw`), `JSON_TRY_USER` (overriding `try`), and `JSON_CATCH_USER` (overriding `catch`). Note that `JSON_THROW_USER` should leave the current scope (e.g., by throwing or aborting), as continuing after it may yield undefined behavior.
|
||||
- **Exceptions** are used widely within the library. They can, however, be switched off with either using the compiler flag `-fno-exceptions` or by defining the symbol `JSON_NOEXCEPTION`. In this case, exceptions are replaced by `abort()` calls. You can further control this behavior by defining `JSON_THROW_USER` (overriding `throw`), `JSON_TRY_USER` (overriding `try`), and `JSON_CATCH_USER` (overriding `catch`). Note that `JSON_THROW_USER` should leave the current scope (e.g., by throwing or aborting), as continuing after it may yield undefined behavior.
|
||||
|
||||
## Execute unit tests
|
||||
|
||||
@@ -1557,4 +1630,10 @@ $ cmake --build .
|
||||
$ ctest --output-on-failure
|
||||
```
|
||||
|
||||
For more information, have a look at the file [.travis.yml](https://github.com/nlohmann/json/blob/master/.travis.yml).
|
||||
Note that during the `ctest` stage, several JSON test files are downloaded from an [external repository](https://github.com/nlohmann/json_test_data). If policies forbid downloading artifacts during testing, you can download the files yourself and pass the directory with the test files via `-DJSON_TestDataDirectory=path` to CMake. Then, no Internet connectivity is required. See [issue #2189](https://github.com/nlohmann/json/issues/2189) for more information.
|
||||
|
||||
In case you have downloaded the library rather than checked out the code via Git, test `cmake_fetch_content_configure`. Please execute `ctest -LE git_required` to skip these tests. See [issue #2189](https://github.com/nlohmann/json/issues/2189) for more information.
|
||||
|
||||
Some tests change the installed files and hence make the whole process not reproducible. Please execute `ctest -LE not_reproducible` to skip these tests. See [issue #2324](https://github.com/nlohmann/json/issues/2324) for more information.
|
||||
|
||||
As Intel compilers use unsafe floating point optimization by default, the unit tests may fail. Use flag [`/fp:precise`](https://software.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/compiler-reference/compiler-options/compiler-option-details/floating-point-options/fp-model-fp.html) then.
|
||||
|
||||
23
appveyor.yml
23
appveyor.yml
@@ -7,6 +7,7 @@ environment:
|
||||
platform: x86
|
||||
CXX_FLAGS: ""
|
||||
LINKER_FLAGS: ""
|
||||
CMAKE_OPTIONS: ""
|
||||
GENERATOR: Visual Studio 14 2015
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
@@ -14,6 +15,7 @@ environment:
|
||||
platform: x86
|
||||
CXX_FLAGS: ""
|
||||
LINKER_FLAGS: ""
|
||||
CMAKE_OPTIONS: ""
|
||||
GENERATOR: Visual Studio 15 2017
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
@@ -21,6 +23,7 @@ environment:
|
||||
platform: x86
|
||||
CXX_FLAGS: ""
|
||||
LINKER_FLAGS: ""
|
||||
CMAKE_OPTIONS: ""
|
||||
GENERATOR: Visual Studio 16 2019
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
@@ -28,6 +31,7 @@ environment:
|
||||
platform: x64
|
||||
CXX_FLAGS: ""
|
||||
LINKER_FLAGS: ""
|
||||
CMAKE_OPTIONS: ""
|
||||
GENERATOR: Visual Studio 16 2019
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
@@ -36,6 +40,7 @@ environment:
|
||||
platform: x86
|
||||
CXX_FLAGS: ""
|
||||
LINKER_FLAGS: ""
|
||||
CMAKE_OPTIONS: ""
|
||||
GENERATOR: Ninja
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
@@ -44,6 +49,7 @@ environment:
|
||||
platform: x86
|
||||
CXX_FLAGS: ""
|
||||
LINKER_FLAGS: ""
|
||||
CMAKE_OPTIONS: ""
|
||||
GENERATOR: Ninja
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
@@ -51,6 +57,7 @@ environment:
|
||||
platform: x86
|
||||
CXX_FLAGS: ""
|
||||
LINKER_FLAGS: ""
|
||||
CMAKE_OPTIONS: ""
|
||||
GENERATOR: Visual Studio 14 2015
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
@@ -59,6 +66,7 @@ environment:
|
||||
name: with_win_header
|
||||
CXX_FLAGS: ""
|
||||
LINKER_FLAGS: ""
|
||||
CMAKE_OPTIONS: ""
|
||||
GENERATOR: Visual Studio 14 2015
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
@@ -66,6 +74,7 @@ environment:
|
||||
platform: x86
|
||||
CXX_FLAGS: "/permissive- /std:c++latest /utf-8"
|
||||
LINKER_FLAGS: ""
|
||||
CMAKE_OPTIONS: ""
|
||||
GENERATOR: Visual Studio 15 2017
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
@@ -73,6 +82,15 @@ environment:
|
||||
platform: x86
|
||||
CXX_FLAGS: ""
|
||||
LINKER_FLAGS: ""
|
||||
CMAKE_OPTIONS: "-DJSON_ImplicitConversions=OFF"
|
||||
GENERATOR: Visual Studio 16 2019
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
configuration: Release
|
||||
platform: x64
|
||||
CXX_FLAGS: ""
|
||||
LINKER_FLAGS: ""
|
||||
CMAKE_OPTIONS: ""
|
||||
GENERATOR: Visual Studio 16 2019
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
@@ -80,6 +98,7 @@ environment:
|
||||
platform: x64
|
||||
CXX_FLAGS: ""
|
||||
LINKER_FLAGS: ""
|
||||
CMAKE_OPTIONS: ""
|
||||
GENERATOR: Visual Studio 14 2015
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
@@ -87,6 +106,7 @@ environment:
|
||||
platform: x64
|
||||
CXX_FLAGS: "/permissive- /std:c++latest /Zc:__cplusplus /utf-8 /F4000000"
|
||||
LINKER_FLAGS: "/STACK:4000000"
|
||||
CMAKE_OPTIONS: ""
|
||||
GENERATOR: Visual Studio 15 2017
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
@@ -94,6 +114,7 @@ environment:
|
||||
platform: x64
|
||||
CXX_FLAGS: ""
|
||||
LINKER_FLAGS: ""
|
||||
CMAKE_OPTIONS: ""
|
||||
GENERATOR: Visual Studio 16 2019
|
||||
|
||||
init:
|
||||
@@ -112,7 +133,7 @@ before_build:
|
||||
# for with_win_header build, inject the inclusion of Windows.h to the single-header library
|
||||
- ps: if ($env:name -Eq "with_win_header") { $header_path = "single_include\nlohmann\json.hpp" }
|
||||
- ps: if ($env:name -Eq "with_win_header") { "#include <Windows.h>`n" + (Get-Content $header_path | Out-String) | Set-Content $header_path }
|
||||
- if "%GENERATOR%"=="Ninja" (cmake . -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%configuration%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" -DJSON_BuildTests=On) else (cmake . -G "%GENERATOR%" -A "%GENERATOR_PLATFORM%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" -DJSON_BuildTests=On)
|
||||
- if "%GENERATOR%"=="Ninja" (cmake . -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%configuration%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" -DJSON_BuildTests=On "%CMAKE_OPTIONS%") else (cmake . -G "%GENERATOR%" -A "%GENERATOR_PLATFORM%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" -DJSON_BuildTests=On "%CMAKE_OPTIONS%")
|
||||
|
||||
build_script:
|
||||
- cmake --build . --config "%configuration%"
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
find_package(Git)
|
||||
|
||||
set(JSON_TEST_DATA_URL https://github.com/nlohmann/json_test_data)
|
||||
set(JSON_TEST_DATA_VERSION 2.0.0)
|
||||
set(JSON_TEST_DATA_VERSION 3.0.0)
|
||||
|
||||
# target to download test data
|
||||
add_custom_target(download_test_data
|
||||
COMMAND test -d json_test_data || ${GIT_EXECUTABLE} clone -c advice.detachedHead=false --branch v${JSON_TEST_DATA_VERSION} ${JSON_TEST_DATA_URL}.git --quiet --depth 1
|
||||
COMMENT "Downloading test data from ${JSON_TEST_DATA_URL} (v${JSON_TEST_DATA_VERSION})"
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
|
||||
# create a header with the path to the downloaded test data
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/include/test_data.hpp "#define TEST_DATA_DIRECTORY \"${CMAKE_BINARY_DIR}/json_test_data\"\n")
|
||||
# if variable is set, use test data from given directory rather than downloading them
|
||||
if(JSON_TestDataDirectory)
|
||||
message(STATUS "Using test data in ${JSON_TestDataDirectory}.")
|
||||
add_custom_target(download_test_data)
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/include/test_data.hpp "#define TEST_DATA_DIRECTORY \"${JSON_TestDataDirectory}\"\n")
|
||||
else()
|
||||
find_package(Git)
|
||||
# target to download test data
|
||||
add_custom_target(download_test_data
|
||||
COMMAND test -d json_test_data || ${GIT_EXECUTABLE} clone -c advice.detachedHead=false --branch v${JSON_TEST_DATA_VERSION} ${JSON_TEST_DATA_URL}.git --quiet --depth 1
|
||||
COMMENT "Downloading test data from ${JSON_TEST_DATA_URL} (v${JSON_TEST_DATA_VERSION})"
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
# create a header with the path to the downloaded test data
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/include/test_data.hpp "#define TEST_DATA_DIRECTORY \"${CMAKE_BINARY_DIR}/json_test_data\"\n")
|
||||
endif()
|
||||
|
||||
# determine the operating system (for debug and support purposes)
|
||||
find_program(UNAME_COMMAND uname)
|
||||
@@ -43,7 +48,7 @@ message(STATUS "Operating system: ${OS_VERSION_STRINGS}")
|
||||
# determine the compiler (for debug and support purposes)
|
||||
if (MSVC)
|
||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} OUTPUT_VARIABLE CXX_VERSION_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_VARIABLE CXX_VERSION_RESULT ERROR_STRIP_TRAILING_WHITESPACE)
|
||||
set(CMAKE_CXX_COMPILER "${CXX_VERSION_RESULT}; MSVC_VERSION=${MSVC_VERSION}; MSVC_TOOLSET_VERSION=${MSVC_TOOLSET_VERSION}")
|
||||
set(CXX_VERSION_RESULT "${CXX_VERSION_RESULT}; MSVC_VERSION=${MSVC_VERSION}; MSVC_TOOLSET_VERSION=${MSVC_TOOLSET_VERSION}")
|
||||
else()
|
||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE CXX_VERSION_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
endif()
|
||||
|
||||
4
cmake/pkg-config.pc.in
Normal file
4
cmake/pkg-config.pc.in
Normal file
@@ -0,0 +1,4 @@
|
||||
Name: ${PROJECT_NAME}
|
||||
Description: JSON for Modern C++
|
||||
Version: ${PROJECT_VERSION}
|
||||
Cflags: -I${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}
|
||||
10
doc/Doxyfile
10
doc/Doxyfile
@@ -1,11 +1,11 @@
|
||||
# Doxyfile 1.8.19
|
||||
# Doxyfile 1.9.0
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = "JSON for Modern C++"
|
||||
PROJECT_NUMBER = 3.8.0
|
||||
PROJECT_NUMBER = 3.9.1
|
||||
PROJECT_BRIEF =
|
||||
PROJECT_LOGO =
|
||||
OUTPUT_DIRECTORY = .
|
||||
@@ -26,6 +26,7 @@ JAVADOC_AUTOBRIEF = NO
|
||||
JAVADOC_BANNER = NO
|
||||
QT_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
PYTHON_DOCSTRING = YES
|
||||
INHERIT_DOCS = YES
|
||||
SEPARATE_MEMBER_PAGES = YES
|
||||
TAB_SIZE = 4
|
||||
@@ -54,6 +55,7 @@ INLINE_GROUPED_CLASSES = NO
|
||||
INLINE_SIMPLE_STRUCTS = NO
|
||||
TYPEDEF_HIDES_STRUCT = NO
|
||||
LOOKUP_CACHE_SIZE = 0
|
||||
NUM_PROC_THREADS = 1
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -65,6 +67,7 @@ EXTRACT_STATIC = YES
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = YES
|
||||
EXTRACT_ANON_NSPACES = YES
|
||||
RESOLVE_UNNAMED_PARAMS = YES
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
@@ -143,7 +146,6 @@ VERBATIM_HEADERS = NO
|
||||
# Configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = YES
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
IGNORE_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the HTML output
|
||||
@@ -307,6 +309,8 @@ COLLABORATION_GRAPH = NO
|
||||
GROUP_GRAPHS = YES
|
||||
UML_LOOK = YES
|
||||
UML_LIMIT_NUM_FIELDS = 10
|
||||
DOT_UML_DETAILS = NO
|
||||
DOT_WRAP_THRESHOLD = 17
|
||||
TEMPLATE_RELATIONS = NO
|
||||
INCLUDE_GRAPH = NO
|
||||
INCLUDED_BY_GRAPH = NO
|
||||
|
||||
@@ -43,7 +43,9 @@ check_output: $(EXAMPLES:.cpp=.test)
|
||||
|
||||
|
||||
clean:
|
||||
rm -fr me.nlohmann.json.docset html $(EXAMPLES:.cpp=)
|
||||
rm -fr me.nlohmann.json.docset html xml $(EXAMPLES:.cpp=)
|
||||
$(MAKE) clean -C docset
|
||||
$(MAKE) clean -C mkdocs
|
||||
|
||||
|
||||
##########################################################################
|
||||
|
||||
BIN
doc/avatars.png
BIN
doc/avatars.png
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
20
doc/docset/Info.plist
Normal file
20
doc/docset/Info.plist
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>nlohmann_json</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>JSON for Modern C++</string>
|
||||
<key>DocSetPlatformFamily</key>
|
||||
<string>json</string>
|
||||
<key>isDashDocset</key>
|
||||
<true/>
|
||||
<key>dashIndexFilePath</key>
|
||||
<string>index.html</string>
|
||||
<key>DashDocSetFallbackURL</key>
|
||||
<string>https://nlohmann.github.io/json/</string>
|
||||
<key>isJavaScriptEnabled</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
21
doc/docset/Makefile
Normal file
21
doc/docset/Makefile
Normal file
@@ -0,0 +1,21 @@
|
||||
nlohmann_json.docset: Info.plist docSet.sql
|
||||
$(MAKE) clean
|
||||
mkdir -p nlohmann_json.docset/Contents/Resources/Documents/
|
||||
cp info.plist nlohmann_json.docset/Contents
|
||||
# build and copy documentation
|
||||
$(MAKE) build -C ../mkdocs
|
||||
cp -r ../mkdocs/site/* nlohmann_json.docset/Contents/Resources/Documents
|
||||
# patch CSS to hide navigation items
|
||||
echo "\n\nheader, footer, navi, div.md-sidebar--primary, nav.md-tabs--active, a.md-content__button { display: none; }" >> nlohmann_json.docset/Contents/Resources/Documents/assets/stylesheets/main.b5d04df8.min.css
|
||||
# fix spacing
|
||||
echo "\n\ndiv.md-sidebar div.md-sidebar--secondary, div.md-main__inner { top: 0; margin-top: 0 }" >> nlohmann_json.docset/Contents/Resources/Documents/assets/stylesheets/main.b5d04df8.min.css
|
||||
# remove "JSON for Modern C++" from page titles
|
||||
find nlohmann_json.docset/Contents/Resources/Documents -type f -exec gsed -i 's| - JSON for Modern C++</title>|</title>|' {} +
|
||||
# clean up
|
||||
rm nlohmann_json.docset/Contents/Resources/Documents/hooks.py
|
||||
rm nlohmann_json.docset/Contents/Resources/Documents/sitemap.*
|
||||
# generate index
|
||||
sqlite3 nlohmann_json.docset/Contents/Resources/docSet.dsidx < docSet.sql
|
||||
|
||||
clean:
|
||||
rm -fr nlohmann_json.docset
|
||||
13
doc/docset/README.md
Normal file
13
doc/docset/README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# docset
|
||||
|
||||
The folder contains the required files to create a [docset](https://kapeli.com/docsets) which can be used in
|
||||
documentation browsers like [Dash](https://kapeli.com/dash), [Velocity](https://velocity.silverlakesoftware.com), or
|
||||
[Zeal](https://zealdocs.org).
|
||||
|
||||
The docset can be created with
|
||||
|
||||
```sh
|
||||
make nlohmann_json.docset
|
||||
```
|
||||
|
||||
The generated folder `nlohmann_json.docset` can then be opened in the documentation browser.
|
||||
140
doc/docset/docSet.sql
Normal file
140
doc/docset/docSet.sql
Normal file
@@ -0,0 +1,140 @@
|
||||
DROP TABLE IF EXISTS searchIndex;
|
||||
CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT);
|
||||
CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path);
|
||||
|
||||
-- API
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('accept', 'Function', 'api/basic_json/accept/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('adl_serializer', 'Class', 'api/adl_serializer/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('array', 'Function', 'api/basic_json/array/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('array_t', 'Type', 'api/basic_json/array_t/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('at', 'Method', 'api/basic_json/at/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('back', 'Method', 'api/basic_json/back/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('basic_json', 'Class', 'api/basic_json/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('basic_json', 'Constructor', 'api/basic_json/basic_json/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('begin', 'Method', 'api/basic_json/begin/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('binary', 'Function', 'api/basic_json/binary/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('binary_t', 'Type', 'api/basic_json/binary_t/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('boolean_t', 'Type', 'api/basic_json/boolean_t/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('cbegin', 'Method', 'api/basic_json/cbegin/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('cbor_tag_handler_t', 'Enum', 'api/basic_json/cbor_tag_handler_t/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('cend', 'Method', 'api/basic_json/cend/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('clear', 'Method', 'api/basic_json/clear/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('contains', 'Method', 'api/basic_json/contains/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('count', 'Method', 'api/basic_json/count/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('crbegin', 'Method', 'api/basic_json/crbegin/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('crend', 'Method', 'api/basic_json/crend/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('diff', 'Function', 'api/basic_json/diff/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('dump', 'Method', 'api/basic_json/dump/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('emplace', 'Method', 'api/basic_json/emplace/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('emplace_back', 'Method', 'api/basic_json/emplace_back/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('empty', 'Method', 'api/basic_json/empty/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('end', 'Method', 'api/basic_json/end/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('erase', 'Method', 'api/basic_json/erase/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('error_handler_t', 'Enum', 'api/basic_json/error_handler_t/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('exception', 'Class', 'api/basic_json/exception/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('find', 'Method', 'api/basic_json/find/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('flatten', 'Method', 'api/basic_json/flatten/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('from_bson', 'Function', 'api/basic_json/from_bson/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('from_cbor', 'Function', 'api/basic_json/from_cbor/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('from_msgpack', 'Function', 'api/basic_json/from_msgpack/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('from_ubjson', 'Function', 'api/basic_json/from_ubjson/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('front', 'Method', 'api/basic_json/front/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('get', 'Method', 'api/basic_json/get/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('get_allocator', 'Function', 'api/basic_json/get_allocator/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('get_binary', 'Method', 'api/basic_json/get_binary/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('get_ptr', 'Method', 'api/basic_json/get_ptr/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('get_ref', 'Method', 'api/basic_json/get_ref/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('get_to', 'Method', 'api/basic_json/get_to/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('input_format_t', 'Enum', 'api/basic_json/input_format_t/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('insert', 'Method', 'api/basic_json/insert/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('invalid_iterator', 'Class', 'api/basic_json/invalid_iterator/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('is_array', 'Method', 'api/basic_json/is_array/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('is_binary', 'Method', 'api/basic_json/is_binary/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('is_boolean', 'Method', 'api/basic_json/is_boolean/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('is_discarded', 'Method', 'api/basic_json/is_discarded/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('is_null', 'Method', 'api/basic_json/is_null/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('is_number', 'Method', 'api/basic_json/is_number/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('is_number_float', 'Method', 'api/basic_json/is_number_float/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('is_number_integer', 'Method', 'api/basic_json/is_number_integer/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('is_number_unsigned', 'Method', 'api/basic_json/is_number_unsigned/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('is_object', 'Method', 'api/basic_json/is_object/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('is_primitive', 'Method', 'api/basic_json/is_primitive/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('is_string', 'Method', 'api/basic_json/is_string/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('is_structured', 'Method', 'api/basic_json/is_structured/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('items', 'Method', 'api/basic_json/items/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('json', 'Class', 'api/json/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('json_pointer', 'Class', 'api/json_pointer/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('json_serializer', 'Type', 'api/basic_json/json_serializer/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('max_size', 'Method', 'api/basic_json/max_size/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('merge_patch', 'Method', 'api/basic_json/merge_patch/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('meta', 'Function', 'api/basic_json/meta/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('number_float_t', 'Type', 'api/basic_json/number_float_t/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('number_integer_t', 'Type', 'api/basic_json/number_integer_t/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('number_unsigned_t', 'Type', 'api/basic_json/number_unsigned_t/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('object', 'Function', 'api/basic_json/object/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('object_comparator_t', 'Type', 'api/basic_json/object_comparator_t/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('object_t', 'Type', 'api/basic_json/object_t/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('operator!=', 'Operator', 'api/basic_json/operator_ne/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('operator+=', 'Operator', 'api/basic_json/operator+=/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('operator=', 'Operator', 'api/basic_json/operator=/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('operator==', 'Operator', 'api/basic_json/operator_eq/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('operator<', 'Operator', 'api/basic_json/operator_lt/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('operator<=', 'Operator', 'api/basic_json/operator_le/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('operator>', 'Operator', 'api/basic_json/operator_gt/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('operator>=', 'Operator', 'api/basic_json/operator_ge/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('operator[]', 'Operator', 'api/basic_json/operator[]/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('operator""_json', 'Literal', 'api/basic_json/operator_literal_json/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('operator""_json_pointer', 'Literal', 'api/basic_json/operator_literal_json_pointer/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('operator ValueType', 'Operator', 'api/basic_json/operator_ValueType/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('operator value_t', 'Operator', 'api/basic_json/operator_value_t/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('ordered_json', 'Class', 'api/ordered_json/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('ordered_map', 'Class', 'api/ordered_map/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('out_of_range', 'Class', 'api/basic_json/out_of_range/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('other_error', 'Class', 'api/basic_json/other_error/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('parse', 'Function', 'api/basic_json/parse/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('parse_error', 'Class', 'api/basic_json/parse_error/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('parse_event_t', 'Enum', 'api/basic_json/parse_event_t/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('parser_callback_t', 'Type', 'api/basic_json/parser_callback_t/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('patch', 'Method', 'api/basic_json/patch/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('push_back', 'Method', 'api/basic_json/push_back/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('rbegin', 'Method', 'api/basic_json/rbegin/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('rend', 'Method', 'api/basic_json/rend/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('sax_parse', 'Function', 'api/basic_json/sax_parse/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('size', 'Method', 'api/basic_json/size/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('string_t', 'Type', 'api/basic_json/string_t/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('type', 'Method', 'api/basic_json/type/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('type_error', 'Class', 'api/basic_json/type_error/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('type_name', 'Method', 'api/basic_json/type_name/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('unflatten', 'Method', 'api/basic_json/unflatten/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('update', 'Method', 'api/basic_json/update/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('to_bson', 'Function', 'api/basic_json/to_bson/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('to_cbor', 'Function', 'api/basic_json/to_cbor/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('to_msgpack', 'Function', 'api/basic_json/to_msgpack/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('to_ubjson', 'Function', 'api/basic_json/to_ubjson/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('value', 'Method', 'api/basic_json/value/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('value_t', 'Enum', 'api/basic_json/value_t/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('~basic_json', 'Method', 'api/basic_json/~basic_json/index.html');
|
||||
|
||||
-- Features
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('Binary Formats', 'Guide', 'features/binary_formats/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('BSON', 'Guide', 'features/binary_formats/bson/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('CBOR', 'Guide', 'features/binary_formats/cbor/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('MessagePack', 'Guide', 'features/binary_formats/messagepack/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('UBJSON', 'Guide', 'features/binary_formats/ubjson/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('Supported Macros', 'Guide', 'features/macros/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('Binary Values', 'Guide', 'features/binary_values/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('Comments', 'Guide', 'features/comments/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('Iterators', 'Guide', 'features/iterators/index.html');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('Types', 'Guide', 'features/types/index.html');
|
||||
|
||||
-- Macros
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('JSON_ASSERT', 'Macro', 'features/macros/index.html#json_assertx');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('JSON_CATCH_USER', 'Macro', 'features/macros/index.html#json_catch_userexception');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('JSON_NOEXCEPTION', 'Macro', 'features/macros/index.html#json_noexception');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('JSON_SKIP_UNSUPPORTED_COMPILER_CHECK', 'Macro', 'features/macros/index.html#json_skip_unsupported_compiler_check');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('JSON_THROW_USER', 'Macro', 'features/macros/index.html#json_throw_userexception');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('JSON_TRY_USER', 'Macro', 'features/macros/index.html#json_try_user');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('JSON_USE_IMPLICIT_CONVERSIONS', 'Macro', 'features/macros/index.html#json_use_implicit_conversions');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_DEFINE_TYPE_INTRUSIVE', 'Macro', 'features/macros/index.html#nlohmann_define_type_intrusivetype-member');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE', 'Macro', 'features/macros/index.html#nlohmann_define_type_non_intrusivetype-member');
|
||||
INSERT INTO searchIndex(name, type, path) VALUES ('NLOHMANN_JSON_SERIALIZE_ENUM', 'Macro', 'features/macros/index.html#nlohmann_json_serialize_enumtype');
|
||||
@@ -1 +1 @@
|
||||
<a target="_blank" href="https://wandbox.org/permlink/EezQxM0Nzi8tTUEe"><b>online</b></a>
|
||||
<a target="_blank" href="https://wandbox.org/permlink/UYcLkpu1GaaAO2Cp"><b>online</b></a>
|
||||
@@ -2,16 +2,16 @@
|
||||
"compiler": {
|
||||
"c++": "201103",
|
||||
"family": "clang",
|
||||
"version": "11.0.3 (clang-1103.0.32.62)"
|
||||
"version": "12.0.0 (clang-1200.0.22.19)"
|
||||
},
|
||||
"copyright": "(C) 2013-2017 Niels Lohmann",
|
||||
"copyright": "(C) 2013-2020 Niels Lohmann",
|
||||
"name": "JSON for Modern C++",
|
||||
"platform": "apple",
|
||||
"url": "https://github.com/nlohmann/json",
|
||||
"version": {
|
||||
"major": 3,
|
||||
"minor": 8,
|
||||
"patch": 0,
|
||||
"string": "3.8.0"
|
||||
"minor": 9,
|
||||
"patch": 1,
|
||||
"string": "3.9.1"
|
||||
}
|
||||
}
|
||||
|
||||
36
doc/examples/parse__allow_exceptions.cpp
Normal file
36
doc/examples/parse__allow_exceptions.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include <iostream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// an invalid JSON text
|
||||
std::string text = R"(
|
||||
{
|
||||
"key": "value without closing quotes
|
||||
}
|
||||
)";
|
||||
|
||||
// parse with exceptions
|
||||
try
|
||||
{
|
||||
json j = json::parse(text);
|
||||
}
|
||||
catch (json::parse_error& e)
|
||||
{
|
||||
std::cout << e.what() << std::endl;
|
||||
}
|
||||
|
||||
// parse without exceptions
|
||||
json j = json::parse(text, nullptr, false);
|
||||
|
||||
if (j.is_discarded())
|
||||
{
|
||||
std::cout << "the input is invalid JSON" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "the input is valid JSON: " << j << std::endl;
|
||||
}
|
||||
}
|
||||
1
doc/examples/parse__allow_exceptions.link
Normal file
1
doc/examples/parse__allow_exceptions.link
Normal file
@@ -0,0 +1 @@
|
||||
<a target="_blank" href="https://wandbox.org/permlink/2TsG4VSg87HsRQC9"><b>online</b></a>
|
||||
2
doc/examples/parse__allow_exceptions.output
Normal file
2
doc/examples/parse__allow_exceptions.output
Normal file
@@ -0,0 +1,2 @@
|
||||
[json.exception.parse_error.101] parse error at line 4, column 0: syntax error while parsing value - invalid string: control character U+000A (LF) must be escaped to \u000A or \n; last read: '"value without closing quotes<U+000A>'
|
||||
the input is invalid JSON
|
||||
@@ -332,4 +332,4 @@ Note that this table only lists those exceptions thrown due to the type. For ins
|
||||
@author [Niels Lohmann](http://nlohmann.me)
|
||||
@see https://github.com/nlohmann/json to download the source code
|
||||
|
||||
@version 3.8.0
|
||||
@version 3.9.1
|
||||
|
||||
BIN
doc/json.gif
BIN
doc/json.gif
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 MiB After Width: | Height: | Size: 1.6 MiB |
@@ -2,6 +2,9 @@
|
||||
serve: prepare_files
|
||||
venv/bin/mkdocs serve
|
||||
|
||||
build: prepare_files
|
||||
venv/bin/mkdocs build
|
||||
|
||||
# create files that are not versioned inside the mkdocs folder
|
||||
prepare_files: clean
|
||||
# build Doxygen
|
||||
@@ -9,7 +12,7 @@ prepare_files: clean
|
||||
# create subfolders
|
||||
mkdir docs/images docs/examples
|
||||
# copy images
|
||||
cp -vr ../json.gif ../images/range-begin-end.svg ../images/range-rbegin-rend.svg docs/images
|
||||
cp -vr ../json.gif ../images/range-begin-end.svg ../images/range-rbegin-rend.svg ../images/callback_events.png docs/images
|
||||
# copy examples
|
||||
cp -vr ../examples/*.cpp ../examples/*.output docs/examples
|
||||
|
||||
|
||||
31
doc/mkdocs/docs/api/adl_serializer.md
Normal file
31
doc/mkdocs/docs/api/adl_serializer.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# adl_serializer
|
||||
|
||||
```cpp
|
||||
template<typename, typename>
|
||||
struct adl_serializer;
|
||||
```
|
||||
|
||||
Serializer that uses ADL ([Argument-Dependent Lookup](https://en.cppreference.com/w/cpp/language/adl)) to choose
|
||||
`to_json`/`from_json` functions from the types' namespaces.
|
||||
|
||||
It is implemented similar to
|
||||
|
||||
```cpp
|
||||
template<typename ValueType>
|
||||
struct adl_serializer {
|
||||
template<typename BasicJsonType>
|
||||
static void to_json(BasicJsonType& j, const T& value) {
|
||||
// calls the "to_json" method in T's namespace
|
||||
}
|
||||
|
||||
template<typename BasicJsonType>
|
||||
static void from_json(const BasicJsonType& j, T& value) {
|
||||
// same thing, but with the "from_json" method
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
## Member functions
|
||||
|
||||
- **from_json** - convert a JSON value to any value type
|
||||
- **to_json** - convert any value type to a JSON value
|
||||
90
doc/mkdocs/docs/api/basic_json/accept.md
Normal file
90
doc/mkdocs/docs/api/basic_json/accept.md
Normal file
@@ -0,0 +1,90 @@
|
||||
# basic_json::accept
|
||||
|
||||
```cpp
|
||||
// (1)
|
||||
template<typename InputType>
|
||||
static bool accept(InputType&& i,
|
||||
const bool ignore_comments = false);
|
||||
|
||||
// (2)
|
||||
template<typename IteratorType>
|
||||
static bool accept(IteratorType first, IteratorType last,
|
||||
const bool ignore_comments = false);
|
||||
```
|
||||
|
||||
Checks whether the input is valid JSON.
|
||||
|
||||
1. Reads from a compatible input.
|
||||
2. Reads from a pair of character iterators
|
||||
|
||||
The value_type of the iterator must be a integral type with size of 1, 2 or 4 bytes, which will be interpreted
|
||||
respectively as UTF-8, UTF-16 and UTF-32.
|
||||
|
||||
Unlike the [`parse`](parse.md) function, this function neither throws an exception in case of invalid JSON input
|
||||
(i.e., a parse error) nor creates diagnostic information.
|
||||
|
||||
## Template parameters
|
||||
|
||||
`InputType`
|
||||
: A compatible input, for instance:
|
||||
|
||||
- an `std::istream` object
|
||||
- a `FILE` pointer
|
||||
- a C-style array of characters
|
||||
- a pointer to a null-terminated string of single byte characters
|
||||
- an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators.
|
||||
|
||||
`IteratorType`
|
||||
: a compatible iterator type
|
||||
|
||||
## Parameters
|
||||
|
||||
`i` (in)
|
||||
: Input to parse from.
|
||||
|
||||
`ignore_comments` (in)
|
||||
: whether comments should be ignored and treated like whitespace (`#!cpp true`) or yield a parse error
|
||||
(`#!cpp false`); (optional, `#!cpp false` by default)
|
||||
|
||||
`first` (in)
|
||||
: iterator to start of character range
|
||||
|
||||
`last` (in)
|
||||
: iterator to end of character range
|
||||
|
||||
## Return value
|
||||
|
||||
Whether the input is valid JSON.
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear in the length of the input. The parser is a predictive LL(1) parser.
|
||||
|
||||
## Notes
|
||||
|
||||
(1) A UTF-8 byte order mark is silently ignored.
|
||||
|
||||
## Examples
|
||||
|
||||
??? example
|
||||
|
||||
The example below demonstrates the `accept()` function reading from a string.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/accept__string.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/accept__string.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.0.0.
|
||||
- Ignoring comments via `ignore_comments` added in version 3.9.0.
|
||||
55
doc/mkdocs/docs/api/basic_json/array.md
Normal file
55
doc/mkdocs/docs/api/basic_json/array.md
Normal file
@@ -0,0 +1,55 @@
|
||||
# basic_json::array
|
||||
|
||||
```cpp
|
||||
static basic_json array(initializer_list_t init = {});
|
||||
```
|
||||
|
||||
Creates a JSON array value from a given initializer list. That is, given a list of values `a, b, c`, creates the JSON
|
||||
value `#!json [a, b, c]`. If the initializer list is empty, the empty array `#!json []` is created.
|
||||
|
||||
## Parameters
|
||||
|
||||
`init` (in)
|
||||
: initializer list with JSON values to create an array from (optional)
|
||||
|
||||
## Return value
|
||||
|
||||
JSON array value
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear in the size of `init`.
|
||||
|
||||
## Notes
|
||||
|
||||
This function is only needed to express two edge cases that cannot be realized with the initializer list constructor
|
||||
([`basic_json(initializer_list_t, bool, value_t)`](basic_json.md)). These cases are:
|
||||
|
||||
1. creating an array whose elements are all pairs whose first element is a string -- in this case, the initializer list
|
||||
constructor would create an object, taking the first elements as keys
|
||||
2. creating an empty array -- passing the empty initializer list to the initializer list constructor yields an empty
|
||||
object
|
||||
|
||||
## Examples
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows an example for the `array` function.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/array.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/array.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
52
doc/mkdocs/docs/api/basic_json/array_t.md
Normal file
52
doc/mkdocs/docs/api/basic_json/array_t.md
Normal file
@@ -0,0 +1,52 @@
|
||||
# basic_json::array_t
|
||||
|
||||
```cpp
|
||||
using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
|
||||
```
|
||||
|
||||
The type used to store JSON arrays.
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) describes JSON arrays as follows:
|
||||
> An array is an ordered sequence of zero or more values.
|
||||
|
||||
To store objects in C++, a type is defined by the template parameters explained below.
|
||||
|
||||
## Template parameters
|
||||
|
||||
`ArrayType`
|
||||
: container type to store arrays (e.g., `std::vector` or `std::list`)
|
||||
|
||||
`AllocatorType`
|
||||
: the allocator to use for objects (e.g., `std::allocator`)
|
||||
|
||||
## Notes
|
||||
|
||||
#### Default type
|
||||
|
||||
With the default values for `ArrayType` (`std::vector`) and `AllocatorType` (`std::allocator`), the default value for
|
||||
`array_t` is:
|
||||
|
||||
```cpp
|
||||
std::vector<
|
||||
basic_json, // value_type
|
||||
std::allocator<basic_json> // allocator_type
|
||||
>
|
||||
```
|
||||
|
||||
#### Limits
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) specifies:
|
||||
> An implementation may set limits on the maximum depth of nesting.
|
||||
|
||||
In this class, the array's limit of nesting is not explicitly constrained. However, a maximum depth of nesting may be
|
||||
introduced by the compiler or runtime environment. A theoretical limit can be queried by calling the
|
||||
[`max_size`](max_size.md) function of a JSON array.
|
||||
|
||||
#### Storage
|
||||
|
||||
Arrays are stored as pointers in a `basic_json` type. That is, for any access to array values, a pointer of type
|
||||
`#!cpp array_t*` must be dereferenced.
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
171
doc/mkdocs/docs/api/basic_json/at.md
Normal file
171
doc/mkdocs/docs/api/basic_json/at.md
Normal file
@@ -0,0 +1,171 @@
|
||||
# basic_json::at
|
||||
|
||||
```cpp
|
||||
// (1)
|
||||
reference at(size_type idx);
|
||||
const_reference at(size_type idx) const;
|
||||
|
||||
// (2)
|
||||
reference at(const typename object_t::key_type& key);
|
||||
const_reference at(const typename object_t::key_type& key) const;
|
||||
|
||||
// (3)
|
||||
reference at(const json_pointer& ptr);
|
||||
const_reference at(const json_pointer& ptr) const;
|
||||
```
|
||||
|
||||
1. Returns a reference to the element at specified location `idx`, with bounds checking.
|
||||
2. Returns a reference to the element at with specified key `key`, with bounds checking.
|
||||
3. Returns a reference to the element at with specified JSON pointer `ptr`, with bounds checking.
|
||||
|
||||
## Parameters
|
||||
|
||||
`idx` (in)
|
||||
: index of the element to access
|
||||
|
||||
`key` (in)
|
||||
: object key of the elements to remove
|
||||
|
||||
`ptr` (in)
|
||||
: JSON pointer to the desired element
|
||||
|
||||
## Return value
|
||||
|
||||
1. reference to the element at index `idx`
|
||||
2. reference to the element at key `key`
|
||||
3. reference to the element pointed to by `ptr`
|
||||
|
||||
## Exceptions
|
||||
|
||||
1. The function can throw the following exceptions:
|
||||
- Throws [`type_error.304`](../../home/exceptions.md#jsonexceptiontype_error304) if the JSON value is not an array;
|
||||
in this case, calling `at` with an index makes no sense. See example below.
|
||||
- Throws [`out_of_range.401`](../../home/exceptions.md#jsonexceptionout_of_range401) if the index `idx` is out of
|
||||
range of the array; that is, `idx >= size()`. See example below.
|
||||
2. The function can throw the following exceptions:
|
||||
- Throws [`type_error.304`](../../home/exceptions.md#jsonexceptiontype_error304) if the JSON value is not an object;
|
||||
in this case, calling `at` with a key makes no sense. See example below.
|
||||
- Throws [`out_of_range.403`](../../home/exceptions.md#jsonexceptionout_of_range403) if the key `key` is is not
|
||||
stored in the object; that is, `find(key) == end()`. See example below.
|
||||
3. The function can throw the following exceptions:
|
||||
- Throws [`parse_error.106`](../../home/exceptions.md#jsonexceptionparse_error106) if an array index in the passed
|
||||
JSON pointer `ptr` begins with '0'. See example below.
|
||||
- Throws [`parse_error.109`](../../home/exceptions.md#jsonexceptionparse_error109) if an array index in the passed
|
||||
JSON pointer `ptr` is not a number. See example below.
|
||||
- Throws [`out_of_range.401`](../../home/exceptions.md#jsonexceptionout_of_range401) if an array index in the passed
|
||||
JSON pointer `ptr` is out of range. See example below.
|
||||
- Throws [`out_of_range.402`](../../home/exceptions.md#jsonexceptionout_of_range402) if the array index '-' is used
|
||||
in the passed JSON pointer `ptr`. As `at` provides checked access (and no elements are implicitly inserted), the
|
||||
index '-' is always invalid. See example below.
|
||||
- Throws [`out_of_range.403`](../../home/exceptions.md#jsonexceptionout_of_range403) if the JSON pointer describes a
|
||||
key of an object which cannot be found. See example below.
|
||||
- Throws [`out_of_range.404`](../../home/exceptions.md#jsonexceptionout_of_range404) if the JSON pointer `ptr` can
|
||||
not be resolved. See example below.
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong exception safety: if an exception occurs, the original value stays intact.
|
||||
|
||||
## Complexity
|
||||
|
||||
1. Constant
|
||||
2. Logarithmic in the size of the container.
|
||||
3. Constant
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The example below shows how array elements can be read and written using `at()`. It also demonstrates the different
|
||||
exceptions that can be thrown.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/at__size_type.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/at__size_type.output"
|
||||
```
|
||||
|
||||
??? example
|
||||
|
||||
The example below shows how array elements can be read using `at()`. It also demonstrates the different exceptions
|
||||
that can be thrown.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/at__size_type_const.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/at__size_type_const.output"
|
||||
```
|
||||
|
||||
??? example
|
||||
|
||||
The example below shows how object elements can be read and written using `at()`. It also demonstrates the different
|
||||
exceptions that can be thrown.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/at__object_t_key_type.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/at__object_t_key_type.output"
|
||||
```
|
||||
|
||||
??? example
|
||||
|
||||
The example below shows how object elements can be read using `at()`. It also demonstrates the different exceptions
|
||||
that can be thrown.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/at__object_t_key_type_const.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/at__object_t_key_type_const.output"
|
||||
```
|
||||
|
||||
??? example
|
||||
|
||||
The example below shows how object elements can be read and written using `at()`. It also demonstrates the different
|
||||
exceptions that can be thrown.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/at_json_pointer.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/at_json_pointer.output"
|
||||
```
|
||||
|
||||
??? example
|
||||
|
||||
The example below shows how object elements can be read using `at()`. It also demonstrates the different exceptions
|
||||
that can be thrown.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/at_json_pointer_const.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/at_json_pointer_const.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
1. Added in version 1.0.0.
|
||||
2. Added in version 1.0.0.
|
||||
3. Added in version 2.0.0.
|
||||
61
doc/mkdocs/docs/api/basic_json/back.md
Normal file
61
doc/mkdocs/docs/api/basic_json/back.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# basic_json::back
|
||||
|
||||
```cpp
|
||||
reference back();
|
||||
|
||||
const_reference back() const;
|
||||
```
|
||||
|
||||
Returns a reference to the last element in the container. For a JSON container `c`, the expression `c.back()` is
|
||||
equivalent to
|
||||
|
||||
```cpp
|
||||
auto tmp = c.end();
|
||||
--tmp;
|
||||
return *tmp;
|
||||
```
|
||||
|
||||
## Return value
|
||||
|
||||
In case of a structured type (array or object), a reference to the last element is returned. In case of number, string,
|
||||
boolean, or binary values, a reference to the value is returned.
|
||||
|
||||
## Exceptions
|
||||
|
||||
If the JSON value is `#!json null`, exception
|
||||
[`invalid_iterator.214`](../../home/exceptions.md#jsonexceptioninvalid_iterator214) is thrown.
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Note
|
||||
|
||||
!!! danger
|
||||
|
||||
Calling `back` on an empty array or object is undefined behavior and is **guarded by an assertion**!
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows an example for `back()`.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/back.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/back.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
- Adjusted code to return reference to binary values in version 3.8.0.
|
||||
394
doc/mkdocs/docs/api/basic_json/basic_json.md
Normal file
394
doc/mkdocs/docs/api/basic_json/basic_json.md
Normal file
@@ -0,0 +1,394 @@
|
||||
# basic_json::basic_json
|
||||
|
||||
```cpp
|
||||
// 1
|
||||
basic_json(const value_t v);
|
||||
|
||||
// 2
|
||||
basic_json(std::nullptr_t = nullptr) noexcept;
|
||||
|
||||
// 3
|
||||
template<typename CompatibleType>
|
||||
basic_json(CompatibleType&& val) noexcept(noexcept(
|
||||
JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
|
||||
std::forward<CompatibleType>(val))));
|
||||
|
||||
// 4
|
||||
template<typename BasicJsonType>
|
||||
basic_json(const BasicJsonType& val);
|
||||
|
||||
// 5
|
||||
basic_json(initializer_list_t init,
|
||||
bool type_deduction = true,
|
||||
value_t manual_type = value_t::array);
|
||||
|
||||
// 6
|
||||
basic_json(size_type cnt, const basic_json& val);
|
||||
|
||||
// 7
|
||||
basic_json(iterator first, iterator last);
|
||||
basic_json(const_iterator first, const_iterator last);
|
||||
|
||||
// 8
|
||||
basic_json(const basic_json& other);
|
||||
|
||||
// 9
|
||||
basic_json(basic_json&& other) noexcept;
|
||||
```
|
||||
|
||||
1. Create an empty JSON value with a given type. The value will be default initialized with an empty value which depends
|
||||
on the type:
|
||||
|
||||
Value type | initial value
|
||||
----------- | -------------
|
||||
null | `#!json null`
|
||||
boolean | `#!json false`
|
||||
string | `#!json ""`
|
||||
number | `#!json 0`
|
||||
object | `#!json {}`
|
||||
array | `#!json []`
|
||||
binary | empty array
|
||||
|
||||
2. Create a `#!json null` JSON value. It either takes a null pointer as parameter (explicitly creating `#!json null`)
|
||||
or no parameter (implicitly creating `#!json null`). The passed null pointer itself is not read -- it is only used to
|
||||
choose the right constructor.
|
||||
|
||||
3. This is a "catch all" constructor for all compatible JSON types; that is, types for which a `to_json()` method
|
||||
exists. The constructor forwards the parameter `val` to that method (to `json_serializer<U>::to_json` method with
|
||||
`U = uncvref_t<CompatibleType>`, to be exact).
|
||||
|
||||
Template type `CompatibleType` includes, but is not limited to, the following types:
|
||||
|
||||
- **arrays**: [`array_t`](array_t.md) and all kinds of compatible containers such as `std::vector`, `std::deque`,
|
||||
`std::list`, `std::forward_list`, `std::array`, `std::valarray`, `std::set`, `std::unordered_set`, `std::multiset`,
|
||||
and `std::unordered_multiset` with a `value_type` from which a `basic_json` value can be constructed.
|
||||
- **objects**: [`object_t`](object_t.md) and all kinds of compatible associative containers such as `std::map`,
|
||||
`std::unordered_map`, `std::multimap`, and `std::unordered_multimap` with a `key_type` compatible to `string_t`
|
||||
and a `value_type` from which a `basic_json` value can be constructed.
|
||||
- **strings**: `string_t`, string literals, and all compatible string containers can be used.
|
||||
- **numbers**: [`number_integer_t`](number_integer_t.md), [`number_unsigned_t`](number_unsigned_t.md),
|
||||
[`number_float_t`](number_float_t.md), and all convertible number types such as `int`, `size_t`, `int64_t`, `float`
|
||||
or `double` can be used.
|
||||
- **boolean**: `boolean_t` / `bool` can be used.
|
||||
- **binary**: `binary_t` / `std::vector<uint8_t>` may be used; unfortunately because string literals cannot be
|
||||
distinguished from binary character arrays by the C++ type system, all types compatible with `const char*` will be
|
||||
directed to the string constructor instead. This is both for backwards compatibility, and due to the fact that a
|
||||
binary type is not a standard JSON type.
|
||||
|
||||
See the examples below.
|
||||
|
||||
4. This is a constructor for existing `basic_json` types. It does not hijack copy/move constructors, since the parameter
|
||||
has different template arguments than the current ones.
|
||||
|
||||
The constructor tries to convert the internal `m_value` of the parameter.
|
||||
|
||||
5. Creates a JSON value of type array or object from the passed initializer list `init`. In case `type_deduction` is
|
||||
`#!cpp true` (default), the type of the JSON value to be created is deducted from the initializer list `init`
|
||||
according to the following rules:
|
||||
|
||||
1. If the list is empty, an empty JSON object value `{}` is created.
|
||||
2. If the list consists of pairs whose first element is a string, a JSON object value is created where the first
|
||||
elements of the pairs are treated as keys and the second elements are as values.
|
||||
3. In all other cases, an array is created.
|
||||
|
||||
The rules aim to create the best fit between a C++ initializer list and JSON values. The rationale is as follows:
|
||||
|
||||
1. The empty initializer list is written as `#!cpp {}` which is exactly an empty JSON object.
|
||||
2. C++ has no way of describing mapped types other than to list a list of pairs. As JSON requires that keys must be
|
||||
of type string, rule 2 is the weakest constraint one can pose on initializer lists to interpret them as an
|
||||
object.
|
||||
3. In all other cases, the initializer list could not be interpreted as JSON object type, so interpreting it as JSON
|
||||
array type is safe.
|
||||
|
||||
With the rules described above, the following JSON values cannot be expressed by an initializer list:
|
||||
|
||||
- the empty array (`#!json []`): use `array(initializer_list_t)` with an empty initializer list in this case
|
||||
- arrays whose elements satisfy rule 2: use `array(initializer_list_t)` with the same initializer list in this case
|
||||
|
||||
6. Constructs a JSON array value by creating `cnt` copies of a passed value. In case `cnt` is `0`, an empty array is
|
||||
created.
|
||||
|
||||
7. Constructs the JSON value with the contents of the range `[first, last)`. The semantics depends on the different
|
||||
types a JSON value can have:
|
||||
|
||||
- In case of a `#!json null` type, [invalid_iterator.206](../../home/exceptions.md#jsonexceptioninvalid_iterator206)
|
||||
is thrown.
|
||||
- In case of other primitive types (number, boolean, or string), `first` must be `begin()` and `last` must be
|
||||
`end()`. In this case, the value is copied. Otherwise,
|
||||
[`invalid_iterator.204`](../../home/exceptions.md#jsonexceptioninvalid_iterator204) is thrown.
|
||||
- In case of structured types (array, object), the constructor behaves as similar versions for `std::vector` or
|
||||
`std::map`; that is, a JSON array or object is constructed from the values in the range.
|
||||
|
||||
8. Creates a copy of a given JSON value.
|
||||
|
||||
9. Move constructor. Constructs a JSON value with the contents of the given value `other` using move semantics. It
|
||||
"steals" the resources from `other` and leaves it as JSON `#!json null` value.
|
||||
|
||||
## Template parameters
|
||||
|
||||
`CompatibleType`
|
||||
: a type such that:
|
||||
|
||||
- `CompatibleType` is not derived from `std::istream`,
|
||||
- `CompatibleType` is not `basic_json` (to avoid hijacking copy/move constructors),
|
||||
- `CompatibleType` is not a different `basic_json` type (i.e. with different template arguments)
|
||||
- `CompatibleType` is not a `basic_json` nested type (e.g., `json_pointer`, `iterator`, etc.)
|
||||
- `json_serializer<U>` (with `U = uncvref_t<CompatibleType>`) has a `to_json(basic_json_t&, CompatibleType&&)`
|
||||
method
|
||||
|
||||
`BasicJsonType`:
|
||||
: a type such that:
|
||||
|
||||
- `BasicJsonType` is a `basic_json` type.
|
||||
- `BasicJsonType` has different template arguments than `basic_json_t`.
|
||||
|
||||
## Parameters
|
||||
|
||||
`v` (in)
|
||||
: the type of the value to create
|
||||
|
||||
`val` (in)
|
||||
: the value to be forwarded to the respective constructor
|
||||
|
||||
`init` (in)
|
||||
: initializer list with JSON values
|
||||
|
||||
`type_deduction` (in)
|
||||
: internal parameter; when set to `#!cpp true`, the type of the JSON value is deducted from the initializer list
|
||||
`init`; when set to `#!cpp false`, the type provided via `manual_type` is forced. This mode is used by the functions
|
||||
`array(initializer_list_t)` and `object(initializer_list_t)`.
|
||||
|
||||
`manual_type` (in)
|
||||
: internal parameter; when `type_deduction` is set to `#!cpp false`, the created JSON value will use the provided type
|
||||
(only `value_t::array` and `value_t::object` are valid); when `type_deduction` is set to `#!cpp true`, this
|
||||
parameter has no effect
|
||||
|
||||
`cnt` (in)
|
||||
: the number of JSON copies of `val` to create
|
||||
|
||||
`first` (in)
|
||||
: begin of the range to copy from (included)
|
||||
|
||||
`last` (in)
|
||||
: end of the range to copy from (excluded)
|
||||
|
||||
`other` (in)
|
||||
: the JSON value to copy/move
|
||||
|
||||
## Exceptions
|
||||
|
||||
1. /
|
||||
2. The function does not throw exceptions.
|
||||
3. /
|
||||
4. /
|
||||
5. The function can throw the following exceptions:
|
||||
- Throws [`type_error.301`](../../home/exceptions.md#jsonexceptiontype_error301) if `type_deduction` is
|
||||
`#!cpp false`, `manual_type` is `value_t::object`, but `init` contains an element which is not a pair whose first
|
||||
element is a string. In this case, the constructor could not create an object. If `type_deduction` would have been
|
||||
`#!cpp true`, an array would have been created. See `object(initializer_list_t)` for an example.
|
||||
6. /
|
||||
7. The function can throw the following exceptions:
|
||||
- Throws [`invalid_iterator.201`](../../home/exceptions.md#jsonexceptioninvalid_iterator201) if iterators `first`
|
||||
and `last` are not compatible (i.e., do not belong to the same JSON value). In this case, the range
|
||||
`[first, last)` is undefined.
|
||||
- Throws [`invalid_iterator.204`](../../home/exceptions.md#jsonexceptioninvalid_iterator204) if iterators `first`
|
||||
and `last` belong to a primitive type (number, boolean, or string), but `first` does not point to the first
|
||||
element any more. In this case, the range `[first, last)` is undefined. See example code below.
|
||||
- Throws [`invalid_iterator.206`](../../home/exceptions.md#jsonexceptioninvalid_iterator206) if iterators `first`
|
||||
and `last` belong to a `#!json null` value. In this case, the range `[first, last)` is undefined.
|
||||
8. /
|
||||
9. The function does not throw exceptions.
|
||||
|
||||
## Exception safety
|
||||
|
||||
1. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
|
||||
2. No-throw guarantee: this constructor never throws exceptions.
|
||||
3. Depends on the called constructor. For types directly supported by the library (i.e., all types for which no
|
||||
`to_json()` function was provided), strong guarantee holds: if an exception is thrown, there are no changes to any
|
||||
JSON value.
|
||||
4. Depends on the called constructor. For types directly supported by the library (i.e., all types for which no
|
||||
`to_json()` function was provided), strong guarantee holds: if an exception is thrown, there are no changes to any
|
||||
JSON value.
|
||||
5. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
|
||||
6. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
|
||||
7. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
|
||||
8. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
|
||||
9. No-throw guarantee: this constructor never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
1. Constant.
|
||||
2. Constant.
|
||||
3. Usually linear in the size of the passed `val`, also depending on the implementation of the called `to_json()`
|
||||
method.
|
||||
4. Usually linear in the size of the passed `val`, also depending on the implementation of the called `to_json()`
|
||||
method.
|
||||
5. Linear in the size of the initializer list `init`.
|
||||
6. Linear in `cnt`.
|
||||
7. Linear in distance between `first` and `last`.
|
||||
8. Linear in the size of `other`.
|
||||
9. Constant.
|
||||
|
||||
## Notes
|
||||
|
||||
- Overload 5:
|
||||
|
||||
!!! note
|
||||
|
||||
When used without parentheses around an empty initializer list, `basic_json()` is called instead of this
|
||||
function, yielding the JSON `#!json null` value.
|
||||
|
||||
- Overload 7:
|
||||
|
||||
!!! info "Preconditions"
|
||||
|
||||
- Iterators `first` and `last` must be initialized. **This precondition is enforced with an assertion (see
|
||||
warning).** If assertions are switched off, a violation of this precondition yields undefined behavior.
|
||||
- Range `[first, last)` is valid. Usually, this precondition cannot be checked efficiently. Only certain edge
|
||||
cases are detected; see the description of the exceptions above. A violation of this precondition yields
|
||||
undefined behavior.
|
||||
|
||||
!!! warning
|
||||
|
||||
A precondition is enforced with a runtime assertion that will result in calling `std::abort` if this
|
||||
precondition is not met. Assertions can be disabled by defining `NDEBUG` at compile time. See
|
||||
<https://en.cppreference.com/w/cpp/error/assert> for more information.
|
||||
|
||||
- Overload 8:
|
||||
|
||||
!!! info "Postcondition"
|
||||
|
||||
`#!cpp *this == other`
|
||||
|
||||
- Overload 9:
|
||||
|
||||
!!! info "Postconditions"
|
||||
|
||||
- `#!cpp `*this` has the same value as `other` before the call.
|
||||
- `other` is a JSON `#!json null` value
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows the constructor for different `value_t` values.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/basic_json__value_t.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/basic_json__value_t.output"
|
||||
```
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows the constructor with and without a null pointer parameter.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/basic_json__nullptr_t.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/basic_json__nullptr_t.output"
|
||||
```
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows the constructor with several compatible types.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/basic_json__CompatibleType.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/basic_json__CompatibleType.output"
|
||||
```
|
||||
|
||||
??? example
|
||||
|
||||
The example below shows how JSON values are created from initializer lists.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/basic_json__list_init_t.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/basic_json__list_init_t.output"
|
||||
```
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows examples for creating arrays with several copies of a given value.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/basic_json__size_type_basic_json.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/basic_json__size_type_basic_json.output"
|
||||
```
|
||||
|
||||
??? example
|
||||
|
||||
The example below shows several ways to create JSON values by specifying a subrange with iterators.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/basic_json__InputIt_InputIt.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/basic_json__InputIt_InputIt.output"
|
||||
```
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows an example for the copy constructor.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/basic_json__basic_json.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/basic_json__basic_json.output"
|
||||
```
|
||||
|
||||
??? example
|
||||
|
||||
The code below shows the move constructor explicitly called via `std::move`.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/basic_json__moveconstructor.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/basic_json__moveconstructor.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
1. Since version 1.0.0.
|
||||
2. Since version 1.0.0.
|
||||
3. Since version 2.1.0.
|
||||
4. Since version 3.2.0.
|
||||
5. Since version 1.0.0.
|
||||
6. Since version 1.0.0.
|
||||
7. Since version 1.0.0.
|
||||
8. Since version 1.0.0.
|
||||
9. Since version 1.0.0.
|
||||
42
doc/mkdocs/docs/api/basic_json/begin.md
Normal file
42
doc/mkdocs/docs/api/basic_json/begin.md
Normal file
@@ -0,0 +1,42 @@
|
||||
# basic_json::begin
|
||||
|
||||
```cpp
|
||||
iterator begin() noexcept;
|
||||
const_iterator begin() const noexcept;
|
||||
```
|
||||
|
||||
Returns an iterator to the first element.
|
||||
|
||||

|
||||
|
||||
## Return value
|
||||
|
||||
iterator to the first element
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this member function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows an example for `begin()`.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/begin.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/begin.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
50
doc/mkdocs/docs/api/basic_json/binary.md
Normal file
50
doc/mkdocs/docs/api/basic_json/binary.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# basic_json::binary
|
||||
|
||||
```cpp
|
||||
// (1)
|
||||
static basic_json binary(const typename binary_t::container_type& init);
|
||||
static basic_json binary(typename binary_t::container_type&& init);
|
||||
|
||||
// (2)
|
||||
static basic_json binary(const typename binary_t::container_type& init,
|
||||
std::uint8_t subtype);
|
||||
static basic_json binary(typename binary_t::container_type&& init,
|
||||
std::uint8_t subtype);
|
||||
```
|
||||
|
||||
1. Creates a JSON binary array value from a given binary container.
|
||||
2. Creates a JSON binary array value from a given binary container with subtype.
|
||||
|
||||
Binary values are part of various binary formats, such as CBOR, MessagePack, and BSON. This constructor is used to
|
||||
create a value for serialization to those formats.
|
||||
|
||||
## Parameters
|
||||
|
||||
`init` (in)
|
||||
: container containing bytes to use as binary type
|
||||
|
||||
`subtype` (in)
|
||||
: subtype to use in CBOR, MessagePack, and BSON
|
||||
|
||||
## Return value
|
||||
|
||||
JSON binary array value
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear in the size of `init`; constant for `typename binary_t::container_type&& init` versions.
|
||||
|
||||
## Notes
|
||||
|
||||
Note, this function exists because of the difficulty in correctly specifying the correct template overload in the
|
||||
standard value ctor, as both JSON arrays and JSON binary arrays are backed with some form of a `std::vector`. Because
|
||||
JSON binary arrays are a non-standard extension it was decided that it would be best to prevent automatic initialization
|
||||
of a binary array type, for backwards compatibility and so it does not happen on accident.
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.8.0.
|
||||
67
doc/mkdocs/docs/api/basic_json/binary_t.md
Normal file
67
doc/mkdocs/docs/api/basic_json/binary_t.md
Normal file
@@ -0,0 +1,67 @@
|
||||
# basic_json::binary_t
|
||||
|
||||
```cpp
|
||||
using binary_t = byte_container_with_subtype<BinaryType>;
|
||||
```
|
||||
|
||||
This type is a type designed to carry binary data that appears in various serialized formats, such as CBOR's Major Type
|
||||
2, MessagePack's bin, and BSON's generic binary subtype. This type is NOT a part of standard JSON and exists solely for
|
||||
compatibility with these binary types. As such, it is simply defined as an ordered sequence of zero or more byte values.
|
||||
|
||||
Additionally, as an implementation detail, the subtype of the binary data is carried around as a `std::uint8_t`, which
|
||||
is compatible with both of the binary data formats that use binary subtyping, (though the specific numbering is
|
||||
incompatible with each other, and it is up to the user to translate between them).
|
||||
|
||||
[CBOR's RFC 7049](https://tools.ietf.org/html/rfc7049) describes this type as:
|
||||
> Major type 2: a byte string. The string's length in bytes is represented following the rules for positive integers
|
||||
> (major type 0).
|
||||
|
||||
[MessagePack's documentation on the bin type
|
||||
family](https://github.com/msgpack/msgpack/blob/master/spec.md#bin-format-family) describes this type as:
|
||||
> Bin format family stores an byte array in 2, 3, or 5 bytes of extra bytes in addition to the size of the byte array.
|
||||
|
||||
[BSON's specifications](http://bsonspec.org/spec.html) describe several binary types; however, this type is intended to
|
||||
represent the generic binary type which has the description:
|
||||
> Generic binary subtype - This is the most commonly used binary subtype and should be the 'default' for drivers and
|
||||
> tools.
|
||||
|
||||
None of these impose any limitations on the internal representation other than the basic unit of storage be some type of
|
||||
array whose parts are decomposable into bytes.
|
||||
|
||||
The default representation of this binary format is a `#!cpp std::vector<std::uint8_t>`, which is a very common way to
|
||||
represent a byte array in modern C++.
|
||||
|
||||
## Template parameters
|
||||
|
||||
`BinaryType`
|
||||
: container type to store arrays
|
||||
|
||||
## Notes
|
||||
|
||||
#### Default type
|
||||
|
||||
The default values for `BinaryType` is `#!cpp std::vector<std::uint8_t>`.
|
||||
|
||||
#### Storage
|
||||
|
||||
Binary Arrays are stored as pointers in a `basic_json` type. That is, for any access to array values, a pointer of the
|
||||
type `#!cpp binary_t*` must be dereferenced.
|
||||
|
||||
#### Notes on subtypes
|
||||
|
||||
- CBOR
|
||||
- Binary values are represented as byte strings. Subtypes are written as tags.
|
||||
|
||||
- MessagePack
|
||||
- If a subtype is given and the binary array contains exactly 1, 2, 4, 8, or 16 elements, the fixext family (fixext1,
|
||||
fixext2, fixext4, fixext8) is used. For other sizes, the ext family (ext8, ext16, ext32) is used. The subtype is
|
||||
then added as singed 8-bit integer.
|
||||
- If no subtype is given, the bin family (bin8, bin16, bin32) is used.
|
||||
|
||||
- BSON
|
||||
- If a subtype is given, it is used and added as unsigned 8-bit integer.
|
||||
- If no subtype is given, the generic binary subtype 0x00 is used.
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.8.0.
|
||||
26
doc/mkdocs/docs/api/basic_json/boolean_t.md
Normal file
26
doc/mkdocs/docs/api/basic_json/boolean_t.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# basic_json::boolean_t
|
||||
|
||||
```cpp
|
||||
using boolean_t = BooleanType;
|
||||
```
|
||||
|
||||
The type used to store JSON booleans.
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) implicitly describes a boolean as a type which differentiates the two literals
|
||||
`#!json true` and `#!json false`.
|
||||
|
||||
To store objects in C++, a type is defined by the template parameter `BooleanType` which chooses the type to use.
|
||||
|
||||
## Notes
|
||||
|
||||
#### Default type
|
||||
|
||||
With the default values for `BooleanType` (`#!cpp bool`), the default value for `boolean_t` is `#!cpp bool`.
|
||||
|
||||
#### Storage
|
||||
|
||||
Boolean values are stored directly inside a `basic_json` type.
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
41
doc/mkdocs/docs/api/basic_json/cbegin.md
Normal file
41
doc/mkdocs/docs/api/basic_json/cbegin.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# basic_json::cbegin
|
||||
|
||||
```cpp
|
||||
const_iterator cbegin() const noexcept;
|
||||
```
|
||||
|
||||
Returns an iterator to the first element.
|
||||
|
||||

|
||||
|
||||
## Return value
|
||||
|
||||
iterator to the first element
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this member function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows an example for `cbegin()`.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/cbegin.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/cbegin.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
21
doc/mkdocs/docs/api/basic_json/cbor_tag_handler_t.md
Normal file
21
doc/mkdocs/docs/api/basic_json/cbor_tag_handler_t.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# basic_json::cbor_tag_handler_t
|
||||
|
||||
```cpp
|
||||
enum class cbor_tag_handler_t
|
||||
{
|
||||
error,
|
||||
ignore
|
||||
};
|
||||
```
|
||||
|
||||
This enumeration is used in the [`from_cbor`](from_cbor.md) function to choose how to treat tags:
|
||||
|
||||
error
|
||||
: throw a `parse_error` exception in case of a tag
|
||||
|
||||
ignore
|
||||
: ignore tags
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.9.0.
|
||||
41
doc/mkdocs/docs/api/basic_json/cend.md
Normal file
41
doc/mkdocs/docs/api/basic_json/cend.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# basic_json::cend
|
||||
|
||||
```cpp
|
||||
const_iterator cend() const noexcept;
|
||||
```
|
||||
|
||||
Returns an iterator to one past the last element.
|
||||
|
||||

|
||||
|
||||
## Return value
|
||||
|
||||
iterator one past the last element
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this member function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows an example for `cend()`.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/cend.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/cend.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
58
doc/mkdocs/docs/api/basic_json/clear.md
Normal file
58
doc/mkdocs/docs/api/basic_json/clear.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# basic_json::clear
|
||||
|
||||
```cpp
|
||||
void clear() noexcept;
|
||||
```
|
||||
|
||||
Clears the content of a JSON value and resets it to the default value as if [`basic_json(value_t)`](basic_json.md) would
|
||||
have been called with the current value type from [`type()`](type.md):
|
||||
|
||||
Value type | initial value
|
||||
----------- | -------------
|
||||
null | `null`
|
||||
boolean | `false`
|
||||
string | `""`
|
||||
number | `0`
|
||||
binary | An empty byte vector
|
||||
object | `{}`
|
||||
array | `[]`
|
||||
|
||||
Has the same effect as calling
|
||||
|
||||
```.cpp
|
||||
*this = basic_json(type());
|
||||
```
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear in the size of the JSON value.
|
||||
|
||||
## Notes
|
||||
|
||||
All iterators, pointers and references related to this container are invalidated.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The example below shows the effect of `clear()` to different
|
||||
JSON types.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/clear.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/clear.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
- Added support for binary types in version 3.8.0.
|
||||
56
doc/mkdocs/docs/api/basic_json/contains.md
Normal file
56
doc/mkdocs/docs/api/basic_json/contains.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# basic_json::contains
|
||||
|
||||
```cpp
|
||||
template<typename KeyT>
|
||||
bool contains(KeyT && key) const;
|
||||
```
|
||||
|
||||
Check whether an element exists in a JSON object with key equivalent to `key`. If the element is not found or the JSON
|
||||
value is not an object, `#!cpp false` is returned.
|
||||
|
||||
## Template parameters
|
||||
|
||||
`KeyT`
|
||||
: A type for an object key other than `basic_json::json_pointer`.
|
||||
|
||||
## Parameters
|
||||
|
||||
`key` (in)
|
||||
: key value to check its existence.
|
||||
|
||||
## Return value
|
||||
|
||||
`#!cpp true` if an element with specified `key` exists. If no such element with such key is found or the JSON value is
|
||||
not an object, `#!cpp false` is returned.
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong exception safety: if an exception occurs, the original value stays intact.
|
||||
|
||||
## Complexity
|
||||
|
||||
Logarithmic in the size of the JSON object.
|
||||
|
||||
## Notes
|
||||
|
||||
This method always returns `#!cpp false` when executed on a JSON type that is not an object.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The example shows how `contains()` is used.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/contains.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/contains.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.6.0.
|
||||
55
doc/mkdocs/docs/api/basic_json/count.md
Normal file
55
doc/mkdocs/docs/api/basic_json/count.md
Normal file
@@ -0,0 +1,55 @@
|
||||
# basic_json::count
|
||||
|
||||
```cpp
|
||||
template<typename KeyT>
|
||||
size_type count(KeyT&& key) const;
|
||||
```
|
||||
|
||||
Returns the number of elements with key `key`. If `ObjectType` is the default `std::map` type, the return value will
|
||||
always be `0` (`key` was not found) or `1` (`key` was found).
|
||||
|
||||
## Template parameters
|
||||
|
||||
`KeyT`
|
||||
: A type for an object key.
|
||||
|
||||
## Parameters
|
||||
|
||||
`key` (in)
|
||||
: key value of the element to count.
|
||||
|
||||
## Return value
|
||||
|
||||
Number of elements with key `key`. If the JSON value is not an object, the return value will be `0`.
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong exception safety: if an exception occurs, the original value stays intact.
|
||||
|
||||
## Complexity
|
||||
|
||||
Logarithmic in the size of the JSON object.
|
||||
|
||||
## Notes
|
||||
|
||||
This method always returns `0` when executed on a JSON type that is not an object.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The example shows how `count()` is used.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/count.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/count.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
41
doc/mkdocs/docs/api/basic_json/crbegin.md
Normal file
41
doc/mkdocs/docs/api/basic_json/crbegin.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# basic_json::crbegin
|
||||
|
||||
```cpp
|
||||
const_reverse_iterator crbegin() const noexcept;
|
||||
```
|
||||
|
||||
Returns an iterator to the reverse-beginning; that is, the last element.
|
||||
|
||||

|
||||
|
||||
## Return value
|
||||
|
||||
reverse iterator to the first element
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this member function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows an example for `crbegin()`.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/crbegin.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/crbegin.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
42
doc/mkdocs/docs/api/basic_json/crend.md
Normal file
42
doc/mkdocs/docs/api/basic_json/crend.md
Normal file
@@ -0,0 +1,42 @@
|
||||
# basic_json::rend
|
||||
|
||||
```cpp
|
||||
const_reverse_iterator crend() const noexcept;
|
||||
```
|
||||
|
||||
Returns an iterator to the reverse-end; that is, one before the first element. This element acts as a placeholder,
|
||||
attempting to access it results in undefined behavior.
|
||||
|
||||

|
||||
|
||||
## Return value
|
||||
|
||||
reverse iterator to the element following the last element
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this member function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows an example for `eend()`.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/crend.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/crend.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
58
doc/mkdocs/docs/api/basic_json/diff.md
Normal file
58
doc/mkdocs/docs/api/basic_json/diff.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# basic_json::diff
|
||||
|
||||
```cpp
|
||||
static basic_json diff(const basic_json& source,
|
||||
const basic_json& target);
|
||||
```
|
||||
|
||||
Creates a [JSON Patch](http://jsonpatch.com) so that value `source` can be changed into the value `target` by calling
|
||||
[`patch`](patch.md) function.
|
||||
|
||||
For two JSON values `source` and `target`, the following code yields always `#!cpp true`:
|
||||
```cpp
|
||||
source.patch(diff(source, target)) == target;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
`source` (in)
|
||||
: JSON value to compare from
|
||||
|
||||
`target` (in)
|
||||
: JSON value to compare against
|
||||
|
||||
## Return value
|
||||
|
||||
a JSON patch to convert the `source` to `target`
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear in the lengths of `source` and `target`.
|
||||
|
||||
## Note
|
||||
|
||||
Currently, only `remove`, `add`, and `replace` operations are generated.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows how a JSON patch is created as a diff for two JSON values.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/diff.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/diff.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 2.0.0.
|
||||
66
doc/mkdocs/docs/api/basic_json/dump.md
Normal file
66
doc/mkdocs/docs/api/basic_json/dump.md
Normal file
@@ -0,0 +1,66 @@
|
||||
# basic_json::dump
|
||||
|
||||
```cpp
|
||||
string_t dump(const int indent = -1,
|
||||
const char indent_char = ' ',
|
||||
const bool ensure_ascii = false,
|
||||
const error_handler_t error_handler = error_handler_t::strict) const;
|
||||
```
|
||||
|
||||
Serialization function for JSON values. The function tries to mimic Python's `json.dumps()` function, and currently
|
||||
supports its `indent` and `ensure_ascii` parameters.
|
||||
|
||||
## Parameters
|
||||
|
||||
`indent` (in)
|
||||
: If `indent` is nonnegative, then array elements and object members will be pretty-printed with that indent level. An
|
||||
indent level of `0` will only insert newlines. `-1` (the default) selects the most compact representation.
|
||||
|
||||
`indent_char` (in)
|
||||
: The character to use for indentation if `indent` is greater than `0`. The default is ` ` (space).
|
||||
|
||||
`ensure_ascii` (in)
|
||||
: If `ensure_ascii` is true, all non-ASCII characters in the output are escaped with `\uXXXX` sequences, and the
|
||||
result consists of ASCII characters only.
|
||||
|
||||
`error_handler` (in)
|
||||
: how to react on decoding errors; there are three possible values (see [`error_handler_t`](error_handler_t.md):
|
||||
`strict` (throws and exception in case a decoding error occurs; default), `replace` (replace invalid UTF-8 sequences
|
||||
with U+FFFD), and `ignore` (ignore invalid UTF-8 sequences during serialization; all bytes are copied to the output
|
||||
unchanged).
|
||||
|
||||
## Return value
|
||||
|
||||
string containing the serialization of the JSON value
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear.
|
||||
|
||||
## Notes
|
||||
|
||||
Binary values are serialized as object containing two keys:
|
||||
|
||||
- "bytes": an array of bytes as integers
|
||||
- "subtype": the subtype as integer or `#!json null` if the binary has no subtype
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following example shows the effect of different `indent`, `indent_char`, and `ensure_ascii` parameters to the
|
||||
result of the serialization.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/dump.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/dump.output"
|
||||
```
|
||||
56
doc/mkdocs/docs/api/basic_json/emplace.md
Normal file
56
doc/mkdocs/docs/api/basic_json/emplace.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# basic_json::emplace
|
||||
|
||||
```cpp
|
||||
template<class... Args>
|
||||
std::pair<iterator, bool> emplace(Args&& ... args);
|
||||
```
|
||||
|
||||
Inserts a new element into a JSON object constructed in-place with the given `args` if there is no element with the key
|
||||
in the container. If the function is called on a JSON null value, an empty object is created before appending the value
|
||||
created from `args`.
|
||||
|
||||
## Template parameters
|
||||
|
||||
`Args`
|
||||
: compatible types to create a `basic_json` object
|
||||
|
||||
## Parameters
|
||||
|
||||
`args` (in)
|
||||
: arguments to forward to a constructor of `basic_json`
|
||||
|
||||
## Return value
|
||||
|
||||
a pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and
|
||||
a `#!cpp bool` denoting whether the insertion took place.
|
||||
|
||||
## Exceptions
|
||||
|
||||
Throws [`type_error.311`](../../home/exceptions.md#jsonexceptiontype_error311) when called on a type other than JSON
|
||||
object or `#!json null`; example: `"cannot use emplace() with number"`
|
||||
|
||||
## Complexity
|
||||
|
||||
Logarithmic in the size of the container, O(log(`size()`)).
|
||||
|
||||
## Examples
|
||||
|
||||
??? example
|
||||
|
||||
The example shows how `emplace()` can be used to add elements to a JSON object. Note how the `#!json null` value was
|
||||
silently converted to a JSON object. Further note how no value is added if there was already one value stored with
|
||||
the same key.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/emplace.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/emplace.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 2.0.8.
|
||||
54
doc/mkdocs/docs/api/basic_json/emplace_back.md
Normal file
54
doc/mkdocs/docs/api/basic_json/emplace_back.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# basic_json::emplace_back
|
||||
|
||||
```cpp
|
||||
template<class... Args>
|
||||
reference emplace_back(Args&& ... args);
|
||||
```
|
||||
|
||||
Creates a JSON value from the passed parameters `args` to the end of the JSON value. If the function is called on a JSON
|
||||
`#!json null` value, an empty array is created before appending the value created from `args`.
|
||||
|
||||
## Template parameters
|
||||
|
||||
`Args`
|
||||
: compatible types to create a `basic_json` object
|
||||
|
||||
## Parameters
|
||||
|
||||
`args` (in)
|
||||
: arguments to forward to a constructor of `basic_json`
|
||||
|
||||
## Return value
|
||||
|
||||
reference to the inserted element
|
||||
|
||||
## Exceptions
|
||||
|
||||
Throws [`type_error.311`](../../home/exceptions.md#jsonexceptiontype_error311) when called on a type other than JSON
|
||||
array or `#!json null`; example: `"cannot use emplace_back() with number"`
|
||||
|
||||
## Complexity
|
||||
|
||||
Amortized constant.
|
||||
|
||||
## Examples
|
||||
|
||||
??? example
|
||||
|
||||
The example shows how `emplace_back()` can be used to add elements to a JSON array. Note how the `null` value was
|
||||
silently converted to a JSON array.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/emplace_back.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/emplace_back.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 2.0.8.
|
||||
- Returns reference since 3.7.0.
|
||||
66
doc/mkdocs/docs/api/basic_json/empty.md
Normal file
66
doc/mkdocs/docs/api/basic_json/empty.md
Normal file
@@ -0,0 +1,66 @@
|
||||
# basic_json::empty
|
||||
|
||||
```cpp
|
||||
bool empty() const noexcept;
|
||||
```
|
||||
|
||||
Checks if a JSON value has no elements (i.e. whether its [`size()`](size.md) is `0`).
|
||||
|
||||
## Return value
|
||||
|
||||
The return value depends on the different types and is defined as follows:
|
||||
|
||||
Value type | return value
|
||||
----------- | -------------
|
||||
null | `#!cpp true`
|
||||
boolean | `#!cpp false`
|
||||
string | `#!cpp false`
|
||||
number | `#!cpp false`
|
||||
binary | `#!cpp false`
|
||||
object | result of function `object_t::empty()`
|
||||
array | result of function `array_t::empty()`
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant, as long as [`array_t`](array_t.md) and [`object_t`](object_t.md) satisfy the
|
||||
[Container](https://en.cppreference.com/w/cpp/named_req/Container) concept; that is, their `empty()` functions have
|
||||
constant complexity.
|
||||
|
||||
## Possible implementation
|
||||
|
||||
```cpp
|
||||
bool empty() const noexcept
|
||||
{
|
||||
return size() == 0;
|
||||
}
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
This function does not return whether a string stored as JSON value is empty -- it returns whether the JSON container
|
||||
itself is empty which is `#!cpp false` in the case of a string.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code uses `empty()` to check if a JSON object contains any elements.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/empty.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/empty.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
- Extended to return `#!cpp false` for binary types in version 3.8.0.
|
||||
42
doc/mkdocs/docs/api/basic_json/end.md
Normal file
42
doc/mkdocs/docs/api/basic_json/end.md
Normal file
@@ -0,0 +1,42 @@
|
||||
# basic_json::end
|
||||
|
||||
```cpp
|
||||
iterator end() noexcept;
|
||||
const_iterator end() const noexcept;
|
||||
```
|
||||
|
||||
Returns an iterator to one past the last element.
|
||||
|
||||

|
||||
|
||||
## Return value
|
||||
|
||||
iterator one past the last element
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this member function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows an example for `end()`.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/end.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/end.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
177
doc/mkdocs/docs/api/basic_json/erase.md
Normal file
177
doc/mkdocs/docs/api/basic_json/erase.md
Normal file
@@ -0,0 +1,177 @@
|
||||
# basic_json::erase
|
||||
|
||||
```cpp
|
||||
// (1)
|
||||
iterator erase(iterator pos);
|
||||
const_iterator erase(const_iterator pos);
|
||||
|
||||
// (2)
|
||||
iterator erase(iterator first, iterator last);
|
||||
const_iterator erase(const_iterator first, const_iterator last);
|
||||
|
||||
// (3)
|
||||
size_type erase(const typename object_t::key_type& key);
|
||||
|
||||
// (4)
|
||||
void erase(const size_type idx);
|
||||
```
|
||||
|
||||
1. Removes an element from a JSON value specified by iterator `pos`. The iterator `pos` must be valid and
|
||||
dereferenceable. Thus the `end()` iterator (which is valid, but is not dereferenceable) cannot be used as a value for
|
||||
`pos`.
|
||||
|
||||
If called on a primitive type other than `#!json null`, the resulting JSON value will be `#!json null`.
|
||||
|
||||
2. Remove an element range specified by `[first; last)` from a JSON value. The iterator `first` does not need to be
|
||||
dereferenceable if `first == last`: erasing an empty range is a no-op.
|
||||
|
||||
If called on a primitive type other than `#!json null`, the resulting JSON value will be `#!json null`.
|
||||
|
||||
3. Removes an element from a JSON object by key.
|
||||
|
||||
4. Removes an element from a JSON array by index.
|
||||
|
||||
## Parameters
|
||||
|
||||
`pos` (in)
|
||||
: iterator to the element to remove
|
||||
|
||||
`first` (in)
|
||||
: iterator to the beginning of the range to remove
|
||||
|
||||
`last` (in)
|
||||
: iterator past the end of the range to remove
|
||||
|
||||
`key` (in)
|
||||
: object key of the elements to remove
|
||||
|
||||
`idx` (in)
|
||||
: array index of the element to remove
|
||||
|
||||
## Return value
|
||||
|
||||
1. Iterator following the last removed element. If the iterator `pos` refers to the last element, the `end()` iterator
|
||||
is returned.
|
||||
2. Iterator following the last removed element. If the iterator `last` refers to the last element, the `end()` iterator
|
||||
is returned.
|
||||
3. Number of elements removed. If `ObjectType` is the default `std::map` type, the return value will always be `0`
|
||||
(`key` was not found) or `1` (`key` was found).
|
||||
4. /
|
||||
|
||||
## Exceptions
|
||||
|
||||
1. The function can throw the following exceptions:
|
||||
- Throws [`type_error.307`](../../home/exceptions.md#jsonexceptiontype_error307) if called on a `null` value;
|
||||
example: `"cannot use erase() with null"`
|
||||
- Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an
|
||||
iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"`
|
||||
- Throws [`invalid_iterator.205`](../../home/exceptions.md#jsonexceptioninvalid_iterator205) if called on a
|
||||
primitive type with invalid iterator (i.e., any iterator which is not `begin()`); example: `"iterator out of
|
||||
range"`
|
||||
2. The function can throw thw following exceptions:
|
||||
- Throws [`type_error.307`](../../home/exceptions.md#jsonexceptiontype_error307) if called on a `null` value;
|
||||
example: `"cannot use erase() with null"`
|
||||
- Throws [`invalid_iterator.203`](../../home/exceptions.md#jsonexceptioninvalid_iterator203) if called on iterators
|
||||
which does not belong to the current JSON value; example: `"iterators do not fit current value"`
|
||||
- Throws [`invalid_iterator.204`](../../home/exceptions.md#jsonexceptioninvalid_iterator204) if called on a
|
||||
primitive type with invalid iterators (i.e., if `first != begin()` and `last != end()`); example: `"iterators out
|
||||
of range"`
|
||||
3. The function can throw thw following exceptions:
|
||||
- Throws [`type_error.307`](../../home/exceptions.md#jsonexceptiontype_error307) when called on a type other than
|
||||
JSON object; example: `"cannot use erase() with null"`
|
||||
4. The function can throw thw following exceptions:
|
||||
- Throws [`type_error.307`](../../home/exceptions.md#jsonexceptiontype_error307) when called on a type other than
|
||||
JSON object; example: `"cannot use erase() with null"`
|
||||
- Throws [`out_of_range.401`](../../home/exceptions.md#jsonexceptionout_of_range401) when `idx >= size()`; example:
|
||||
`"array index 17 is out of range"`
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong exception safety: if an exception occurs, the original value stays intact.
|
||||
|
||||
## Complexity
|
||||
|
||||
1. The complexity depends on the type:
|
||||
- objects: amortized constant
|
||||
- arrays: linear in distance between `pos` and the end of the container
|
||||
- strings and binary: linear in the length of the member
|
||||
- other types: constant
|
||||
2. The complexity depends on the type:
|
||||
- objects: `log(size()) + std::distance(first, last)`
|
||||
- arrays: linear in the distance between `first` and `last`, plus linear
|
||||
in the distance between `last` and end of the container
|
||||
- strings and binary: linear in the length of the member
|
||||
- other types: constant
|
||||
3. `log(size()) + count(key)`
|
||||
4. Linear in distance between `idx` and the end of the container.
|
||||
|
||||
## Notes
|
||||
|
||||
1. Invalidates iterators and references at or after the point of the
|
||||
erase, including the `end()` iterator.
|
||||
2. /
|
||||
3. References and iterators to the erased elements are invalidated. Other references and iterators are not affected.
|
||||
4. /
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The example shows the effect of `erase()` for different JSON types using an iterator.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/erase__IteratorType.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/erase__IteratorType.output"
|
||||
```
|
||||
|
||||
??? example
|
||||
|
||||
The example shows the effect of `erase()` for different JSON types using an iterator range.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/erase__IteratorType_IteratorType.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/erase__IteratorType_IteratorType.output"
|
||||
```
|
||||
|
||||
??? example
|
||||
|
||||
The example shows the effect of `erase()` for different JSON types using an object key.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/erase__key_type.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/erase__key_type.output"
|
||||
```
|
||||
|
||||
??? example
|
||||
|
||||
The example shows the effect of `erase()` using an array index.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/erase__size_type.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/erase__size_type.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
- Added support for binary types in version 3.8.0.
|
||||
25
doc/mkdocs/docs/api/basic_json/error_handler_t.md
Normal file
25
doc/mkdocs/docs/api/basic_json/error_handler_t.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# basic_json::error_handler_t
|
||||
|
||||
```cpp
|
||||
enum class error_handler_t {
|
||||
strict,
|
||||
replace,
|
||||
ignore
|
||||
};
|
||||
```
|
||||
|
||||
This enumeration is used in the [`dump`](dump.md) function to choose how to treat decoding errors while serializing a
|
||||
`basic_json` value. Three values are differentiated:
|
||||
|
||||
strict
|
||||
: throw a `type_error` exception in case of invalid UTF-8
|
||||
|
||||
replace
|
||||
: replace invalid UTF-8 sequences with U+FFFD (<28> REPLACEMENT CHARACTER)
|
||||
|
||||
ignore
|
||||
: ignore invalid UTF-8 sequences; all bytes are copied to the output unchanged
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.4.0.
|
||||
65
doc/mkdocs/docs/api/basic_json/exception.md
Normal file
65
doc/mkdocs/docs/api/basic_json/exception.md
Normal file
@@ -0,0 +1,65 @@
|
||||
# basic_json::exception
|
||||
|
||||
```cpp
|
||||
class exception : public std::exception;
|
||||
```
|
||||
|
||||
This class is an extension of [`std::exception`](https://en.cppreference.com/w/cpp/error/exception) objects with a
|
||||
member `id` for exception ids. It is used as the base class for all exceptions thrown by the `basic_json` class. This
|
||||
class can hence be used as "wildcard" to catch exceptions, see example below.
|
||||
|
||||
```plantuml
|
||||
std::exception <|-- basic_json::exception
|
||||
basic_json::exception <|-- basic_json::parse_error
|
||||
basic_json::exception <|-- basic_json::invalid_iterator
|
||||
basic_json::exception <|-- basic_json::type_error
|
||||
basic_json::exception <|-- basic_json::out_of_range
|
||||
basic_json::exception <|-- basic_json::other_error
|
||||
|
||||
interface std::exception {}
|
||||
|
||||
class basic_json::exception #FFFF00 {
|
||||
+ const int id
|
||||
+ const char* what() const
|
||||
}
|
||||
|
||||
class basic_json::parse_error {
|
||||
+ const std::size_t byte
|
||||
}
|
||||
```
|
||||
|
||||
Subclasses:
|
||||
|
||||
- [`parse_error`](parse_error.md) for exceptions indicating a parse error
|
||||
- [`invalid_iterator`](invalid_iterator.md) for exceptions indicating errors with iterators
|
||||
- [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type
|
||||
- [`out_of_range`](out_of_range.md) for exceptions indicating access out of the defined range
|
||||
- [`other_error`](other_error.md) for exceptions indicating other library errors
|
||||
|
||||
## Member functions
|
||||
|
||||
- **what** - returns explanatory string
|
||||
|
||||
## Member variables
|
||||
|
||||
- **id** - the id of the exception
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows how arbitrary library exceptions can be caught.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/exception.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/exception.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 3.0.0.
|
||||
59
doc/mkdocs/docs/api/basic_json/find.md
Normal file
59
doc/mkdocs/docs/api/basic_json/find.md
Normal file
@@ -0,0 +1,59 @@
|
||||
# basic_json::find
|
||||
|
||||
```cpp
|
||||
template<typename KeyT>
|
||||
iterator find(KeyT&& key);
|
||||
|
||||
template<typename KeyT>
|
||||
const_iterator find(KeyT&& key) const
|
||||
```
|
||||
|
||||
Finds an element in a JSON object with key equivalent to `key`. If the element is not found or the JSON value is not an
|
||||
object, `end()` is returned.
|
||||
|
||||
## Template parameters
|
||||
|
||||
`KeyT`
|
||||
: A type for an object key.
|
||||
|
||||
## Parameters
|
||||
|
||||
`key` (in)
|
||||
: key value of the element to search for.
|
||||
|
||||
## Return value
|
||||
|
||||
Iterator to an element with key equivalent to `key`. If no such element is found or the JSON value is not an object,
|
||||
past-the-end (see `end()`) iterator is returned.
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong exception safety: if an exception occurs, the original value stays intact.
|
||||
|
||||
## Complexity
|
||||
|
||||
Logarithmic in the size of the JSON object.
|
||||
|
||||
## Notes
|
||||
|
||||
This method always returns `end()` when executed on a JSON type that is not an object.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The example shows how `find()` is used.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/find__key_type.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/find__key_type.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
46
doc/mkdocs/docs/api/basic_json/flatten.md
Normal file
46
doc/mkdocs/docs/api/basic_json/flatten.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# basic_json::flatten
|
||||
|
||||
```cpp
|
||||
basic_json flatten() const;
|
||||
```
|
||||
|
||||
The function creates a JSON object whose keys are JSON pointers (see [RFC 6901](https://tools.ietf.org/html/rfc6901))
|
||||
and whose values are all primitive (see [`is_primitive()`](is_primitive.md) for more information). The original JSON
|
||||
value can be restored using the [`unflatten()`](unflatten.md) function.
|
||||
|
||||
## Return value
|
||||
|
||||
an object that maps JSON pointers to primitive values
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong exception safety: if an exception occurs, the original value stays intact.
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear in the size the JSON value.
|
||||
|
||||
## Notes
|
||||
|
||||
Empty objects and arrays are flattened to `#!json null` and will not be reconstructed correctly by the
|
||||
[`unflatten()`](unflatten.md) function.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows how a JSON object is flattened to an object whose keys consist of JSON pointers.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/flatten.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/flatten.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 2.0.0.
|
||||
83
doc/mkdocs/docs/api/basic_json/from_bson.md
Normal file
83
doc/mkdocs/docs/api/basic_json/from_bson.md
Normal file
@@ -0,0 +1,83 @@
|
||||
# basic_json::from_bson
|
||||
|
||||
```cpp
|
||||
// (1)
|
||||
template<typename InputType>
|
||||
static basic_json from_bson(InputType&& i,
|
||||
const bool strict = true,
|
||||
const bool allow_exceptions = true);
|
||||
// (2)
|
||||
template<typename IteratorType>
|
||||
static basic_json from_bson(IteratorType first, IteratorType last,
|
||||
const bool strict = true,
|
||||
const bool allow_exceptions = true);
|
||||
```
|
||||
|
||||
Deserializes a given input to a JSON value using the BSON (Binary JSON) serialization format.
|
||||
|
||||
1. Reads from a compatible input.
|
||||
2. Reads from an iterator range.
|
||||
|
||||
## Template parameters
|
||||
|
||||
`InputType`
|
||||
: A compatible input, for instance:
|
||||
|
||||
- an `std::istream` object
|
||||
- a `FILE` pointer
|
||||
- a C-style array of characters
|
||||
- a pointer to a null-terminated string of single byte characters
|
||||
- an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators.
|
||||
|
||||
`IteratorType`
|
||||
: a compatible iterator type
|
||||
|
||||
## Parameters
|
||||
|
||||
`i` (in)
|
||||
: an input in BSON format convertible to an input adapter
|
||||
|
||||
`first` (in)
|
||||
: iterator to start of the input
|
||||
|
||||
`last` (in)
|
||||
: iterator to end of the input
|
||||
|
||||
`strict` (in)
|
||||
: whether to expect the input to be consumed until EOF (`#!cpp true` by default)
|
||||
|
||||
`allow_exceptions` (in)
|
||||
: whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default)
|
||||
|
||||
## Return value
|
||||
|
||||
deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be
|
||||
`value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md).
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear in the size of the input.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The example shows the deserialization of a byte vector in BSON format to a JSON value.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/from_bson.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/from_bson.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.4.0.
|
||||
94
doc/mkdocs/docs/api/basic_json/from_cbor.md
Normal file
94
doc/mkdocs/docs/api/basic_json/from_cbor.md
Normal file
@@ -0,0 +1,94 @@
|
||||
# basic_json::from_cbor
|
||||
|
||||
```cpp
|
||||
// (1)
|
||||
template<typename InputType>
|
||||
static basic_json from_cbor(InputType&& i,
|
||||
const bool strict = true,
|
||||
const bool allow_exceptions = true,
|
||||
const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error);
|
||||
|
||||
// (2)
|
||||
template<typename IteratorType>
|
||||
static basic_json from_cbor(IteratorType first, IteratorType last,
|
||||
const bool strict = true,
|
||||
const bool allow_exceptions = true,
|
||||
const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error);
|
||||
```
|
||||
|
||||
Deserializes a given input to a JSON value using the CBOR (Concise Binary Object Representation) serialization format.
|
||||
|
||||
1. Reads from a compatible input.
|
||||
2. Reads from an iterator range.
|
||||
|
||||
## Template parameters
|
||||
|
||||
`InputType`
|
||||
: A compatible input, for instance:
|
||||
|
||||
- an `std::istream` object
|
||||
- a `FILE` pointer
|
||||
- a C-style array of characters
|
||||
- a pointer to a null-terminated string of single byte characters
|
||||
- an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators.
|
||||
|
||||
`IteratorType`
|
||||
: a compatible iterator type
|
||||
|
||||
## Parameters
|
||||
|
||||
`i` (in)
|
||||
: an input in CBOR format convertible to an input adapter
|
||||
|
||||
`first` (in)
|
||||
: iterator to start of the input
|
||||
|
||||
`last` (in)
|
||||
: iterator to end of the input
|
||||
|
||||
`strict` (in)
|
||||
: whether to expect the input to be consumed until EOF (`#!cpp true` by default)
|
||||
|
||||
`allow_exceptions` (in)
|
||||
: whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default)
|
||||
|
||||
`tag_handler` (in)
|
||||
: how to treat CBOR tags (optional, `error` by default); see [`cbor_tag_handler_t`](cbor_tag_handler_t.md) for more
|
||||
information
|
||||
|
||||
## Return value
|
||||
|
||||
deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be
|
||||
`value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md).
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear in the size of the input.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The example shows the deserialization of a byte vector in CBOR format to a JSON value.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/from_cbor.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/from_cbor.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 2.0.9.
|
||||
- Parameter `start_index` since version 2.1.1.
|
||||
- Changed to consume input adapters, removed `start_index` parameter, and added `strict` parameter in version 3.0.0.
|
||||
- Added `allow_exceptions` parameter in version 3.2.0.
|
||||
- Added `tag_handler` parameter in version 3.9.0.
|
||||
86
doc/mkdocs/docs/api/basic_json/from_msgpack.md
Normal file
86
doc/mkdocs/docs/api/basic_json/from_msgpack.md
Normal file
@@ -0,0 +1,86 @@
|
||||
# basic_json::from_msgpack
|
||||
|
||||
```cpp
|
||||
// (1)
|
||||
template<typename InputType>
|
||||
static basic_json from_msgpack(InputType&& i,
|
||||
const bool strict = true,
|
||||
const bool allow_exceptions = true);
|
||||
// (2)
|
||||
template<typename IteratorType>
|
||||
static basic_json from_msgpack(IteratorType first, IteratorType last,
|
||||
const bool strict = true,
|
||||
const bool allow_exceptions = true);
|
||||
```
|
||||
|
||||
Deserializes a given input to a JSON value using the MessagePack serialization format.
|
||||
|
||||
1. Reads from a compatible input.
|
||||
2. Reads from an iterator range.
|
||||
|
||||
## Template parameters
|
||||
|
||||
`InputType`
|
||||
: A compatible input, for instance:
|
||||
|
||||
- an `std::istream` object
|
||||
- a `FILE` pointer
|
||||
- a C-style array of characters
|
||||
- a pointer to a null-terminated string of single byte characters
|
||||
- an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators.
|
||||
|
||||
`IteratorType`
|
||||
: a compatible iterator type
|
||||
|
||||
## Parameters
|
||||
|
||||
`i` (in)
|
||||
: an input in MessagePack format convertible to an input adapter
|
||||
|
||||
`first` (in)
|
||||
: iterator to start of the input
|
||||
|
||||
`last` (in)
|
||||
: iterator to end of the input
|
||||
|
||||
`strict` (in)
|
||||
: whether to expect the input to be consumed until EOF (`#!cpp true` by default)
|
||||
|
||||
`allow_exceptions` (in)
|
||||
: whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default)
|
||||
|
||||
## Return value
|
||||
|
||||
deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be
|
||||
`value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md).
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear in the size of the input.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The example shows the deserialization of a byte vector in MessagePack format to a JSON value.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/from_msgpack.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/from_msgpack.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 2.0.9.
|
||||
- Parameter `start_index` since version 2.1.1.
|
||||
- Changed to consume input adapters, removed `start_index` parameter, and added `strict` parameter in version 3.0.0.
|
||||
- Added `allow_exceptions` parameter in version 3.2.0.
|
||||
84
doc/mkdocs/docs/api/basic_json/from_ubjson.md
Normal file
84
doc/mkdocs/docs/api/basic_json/from_ubjson.md
Normal file
@@ -0,0 +1,84 @@
|
||||
# basic_json::from_ubjson
|
||||
|
||||
```cpp
|
||||
// (1)
|
||||
template<typename InputType>
|
||||
static basic_json from_ubjson(InputType&& i,
|
||||
const bool strict = true,
|
||||
const bool allow_exceptions = true);
|
||||
// (2)
|
||||
template<typename IteratorType>
|
||||
static basic_json from_ubjson(IteratorType first, IteratorType last,
|
||||
const bool strict = true,
|
||||
const bool allow_exceptions = true);
|
||||
```
|
||||
|
||||
Deserializes a given input to a JSON value using the UBJSON (Universal Binary JSON) serialization format.
|
||||
|
||||
1. Reads from a compatible input.
|
||||
2. Reads from an iterator range.
|
||||
|
||||
## Template parameters
|
||||
|
||||
`InputType`
|
||||
: A compatible input, for instance:
|
||||
|
||||
- an `std::istream` object
|
||||
- a `FILE` pointer
|
||||
- a C-style array of characters
|
||||
- a pointer to a null-terminated string of single byte characters
|
||||
- an object `obj` for which `begin(obj)` and `end(obj)` produces a valid pair of iterators.
|
||||
|
||||
`IteratorType`
|
||||
: a compatible iterator type
|
||||
|
||||
## Parameters
|
||||
|
||||
`i` (in)
|
||||
: an input in UBJSON format convertible to an input adapter
|
||||
|
||||
`first` (in)
|
||||
: iterator to start of the input
|
||||
|
||||
`last` (in)
|
||||
: iterator to end of the input
|
||||
|
||||
`strict` (in)
|
||||
: whether to expect the input to be consumed until EOF (`#!cpp true` by default)
|
||||
|
||||
`allow_exceptions` (in)
|
||||
: whether to throw exceptions in case of a parse error (optional, `#!cpp true` by default)
|
||||
|
||||
## Return value
|
||||
|
||||
deserialized JSON value; in case of a parse error and `allow_exceptions` set to `#!cpp false`, the return value will be
|
||||
`value_t::discarded`. The latter can be checked with [`is_discarded`](is_discarded.md).
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear in the size of the input.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The example shows the deserialization of a byte vector in UBJSON format to a JSON value.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/from_ubjson.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/from_ubjson.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.1.0.
|
||||
- Added `allow_exceptions` parameter in version 3.2.0.
|
||||
54
doc/mkdocs/docs/api/basic_json/front.md
Normal file
54
doc/mkdocs/docs/api/basic_json/front.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# basic_json::front
|
||||
|
||||
```cpp
|
||||
reference front();
|
||||
const_reference front() const;
|
||||
```
|
||||
|
||||
Returns a reference to the first element in the container. For a JSON container `#!cpp c`, the expression
|
||||
`#!cpp c.front()` is equivalent to `#!cpp *c.begin()`.
|
||||
|
||||
## Return value
|
||||
|
||||
In case of a structured type (array or object), a reference to the first element is returned. In case of number, string,
|
||||
boolean, or binary values, a reference to the value is returned.
|
||||
|
||||
## Exceptions
|
||||
|
||||
If the JSON value is `#!json null`, exception
|
||||
[`invalid_iterator.214`](../../home/exceptions.md#jsonexceptioninvalid_iterator214) is thrown.
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Note
|
||||
|
||||
!!! danger
|
||||
|
||||
Calling `front` on an empty array or object is undefined behavior and is **guarded by an assertion**!
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows an example for `front()`.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/front.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/front.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
- Adjusted code to return reference to binary values in version 3.8.0.
|
||||
136
doc/mkdocs/docs/api/basic_json/get.md
Normal file
136
doc/mkdocs/docs/api/basic_json/get.md
Normal file
@@ -0,0 +1,136 @@
|
||||
# basic_json::get
|
||||
|
||||
```cpp
|
||||
// (1)
|
||||
template<typename ValueType>
|
||||
ValueType get() const noexcept(
|
||||
noexcept(JSONSerializer<ValueType>::from_json(
|
||||
std::declval<const basic_json_t&>(), std::declval<ValueType&>())));
|
||||
|
||||
// (2)
|
||||
template<typename BasicJsonType>
|
||||
BasicJsonType get() const;
|
||||
|
||||
// (3)
|
||||
template<typename PointerType>
|
||||
PointerType get_ptr();
|
||||
|
||||
template<typename PointerType>
|
||||
constexpr const PointerType get_ptr() const noexcept;
|
||||
```
|
||||
|
||||
1. Explicit type conversion between the JSON value and a compatible value which is
|
||||
[CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible) and
|
||||
[DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). The value is converted by
|
||||
calling the `json_serializer<ValueType>` `from_json()` method.
|
||||
|
||||
The function is equivalent to executing
|
||||
```cpp
|
||||
ValueType ret;
|
||||
JSONSerializer<ValueType>::from_json(*this, ret);
|
||||
return ret;
|
||||
```
|
||||
|
||||
This overloads is chosen if:
|
||||
|
||||
- `ValueType` is not `basic_json`,
|
||||
- `json_serializer<ValueType>` has a `from_json()` method of the form
|
||||
`void from_json(const basic_json&, ValueType&)`, and
|
||||
- `json_serializer<ValueType>` does not have a `from_json()` method of the form
|
||||
`ValueType from_json(const basic_json&)`
|
||||
|
||||
If the type is **not** [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible) and
|
||||
**not** [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible), the value is
|
||||
converted by calling the `json_serializer<ValueType>` `from_json()` method.
|
||||
|
||||
The function is then equivalent to executing
|
||||
```cpp
|
||||
return JSONSerializer<ValueTypeCV>::from_json(*this);
|
||||
```
|
||||
|
||||
This overloads is chosen if:
|
||||
|
||||
- `ValueType` is not `basic_json` and
|
||||
- `json_serializer<ValueType>` has a `from_json()` method of the form
|
||||
`ValueType from_json(const basic_json&)`
|
||||
|
||||
If `json_serializer<ValueType>` has both overloads of `from_json()`, the latter one is chosen.
|
||||
|
||||
2. Overload for `basic_json` specializations. The function is equivalent to executing
|
||||
```cpp
|
||||
return *this;
|
||||
```
|
||||
|
||||
3. Explicit pointer access to the internally stored JSON value. No copies are made.
|
||||
|
||||
## Template parameters
|
||||
|
||||
`ValueType`
|
||||
: the value type to return
|
||||
|
||||
`BasicJsonType`
|
||||
: a specialization of `basic_json`
|
||||
|
||||
`PointerType`
|
||||
: pointer type; must be a pointer to [`array_t`](array_t.md), [`object_t`](object_t.md), [`string_t`](string_t.md),
|
||||
[`boolean_t`](boolean_t.md), [`number_integer_t`](number_integer_t.md), or
|
||||
[`number_unsigned_t`](number_unsigned_t.md), [`number_float_t`](number_float_t.md), or [`binary_t`](binary_t.md).
|
||||
Other types will not compile.
|
||||
|
||||
## Return value
|
||||
|
||||
1. copy of the JSON value, converted to `ValueType`
|
||||
2. a copy of `#!cpp *this`, converted into `BasicJsonType`
|
||||
3. pointer to the internally stored JSON value if the requested pointer type fits to the JSON value; `#!cpp nullptr`
|
||||
otherwise
|
||||
|
||||
## Exceptions
|
||||
|
||||
Depends on what `json_serializer<ValueType>` `from_json()` method throws
|
||||
|
||||
## Notes
|
||||
|
||||
!!! warning
|
||||
|
||||
Writing data to the pointee (overload 3) of the result yields an undefined state.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The example below shows several conversions from JSON values
|
||||
to other types. There a few things to note: (1) Floating-point numbers can
|
||||
be converted to integers, (2) A JSON array can be converted to a standard
|
||||
`std::vector<short>`, (3) A JSON object can be converted to C++
|
||||
associative containers such as `std::unordered_map<std::string, json>`.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/get__ValueType_const.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/get__ValueType_const.output"
|
||||
```
|
||||
|
||||
??? example
|
||||
|
||||
The example below shows how pointers to internal values of a JSON value can be requested. Note that no type
|
||||
conversions are made and a `#cpp nullptr` is returned if the value and the requested pointer type does not match.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/get__PointerType.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/get__PointerType.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
1. Since version 2.1.0.
|
||||
2. Since version 2.1.0. Extended to work with other specializations of `basic_json` in version 3.2.0.
|
||||
3. Since version 1.0.0.
|
||||
15
doc/mkdocs/docs/api/basic_json/get_allocator.md
Normal file
15
doc/mkdocs/docs/api/basic_json/get_allocator.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# basic_json::get_allocator
|
||||
|
||||
```cpp
|
||||
static allocator_type get_allocator();
|
||||
```
|
||||
|
||||
Returns the allocator associated with the container.
|
||||
|
||||
## Return value
|
||||
|
||||
associated allocator
|
||||
|
||||
## Version history
|
||||
|
||||
- Unknown.
|
||||
29
doc/mkdocs/docs/api/basic_json/get_binary.md
Normal file
29
doc/mkdocs/docs/api/basic_json/get_binary.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# basic_json::get_binary
|
||||
|
||||
```cpp
|
||||
binary_t& get_binary();
|
||||
|
||||
const binary_t& get_binary() const;
|
||||
```
|
||||
|
||||
Returns a reference to the stored binary value.
|
||||
|
||||
## Return value
|
||||
|
||||
Reference to binary value.
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong exception safety: if an exception occurs, the original value stays intact.
|
||||
|
||||
## Exceptions
|
||||
|
||||
Throws [`type_error.302`](../../home/exceptions.md#jsonexceptiontype_error302) if the value is not binary
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.8.0.
|
||||
60
doc/mkdocs/docs/api/basic_json/get_ptr.md
Normal file
60
doc/mkdocs/docs/api/basic_json/get_ptr.md
Normal file
@@ -0,0 +1,60 @@
|
||||
# basic_json::get_ptr
|
||||
|
||||
```cpp
|
||||
template<typename PointerType>
|
||||
PointerType get_ptr();
|
||||
|
||||
template<typename PointerType>
|
||||
constexpr const PointerType get_ptr() const noexcept;
|
||||
```
|
||||
|
||||
Implicit pointer access to the internally stored JSON value. No copies are made.
|
||||
|
||||
## Template arguments
|
||||
|
||||
`PointerType`
|
||||
: pointer type; must be a pointer to [`array_t`](array_t.md), [`object_t`](object_t.md), [`string_t`](string_t.md),
|
||||
[`boolean_t`](boolean_t.md), [`number_integer_t`](number_integer_t.md), or
|
||||
[`number_unsigned_t`](number_unsigned_t.md), [`number_float_t`](number_float_t.md), or [`binary_t`](binary_t.md).
|
||||
Other types will not compile.
|
||||
|
||||
## Return value
|
||||
|
||||
pointer to the internally stored JSON value if the requested pointer type fits to the JSON value; `#!cpp nullptr`
|
||||
otherwise
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong exception safety: if an exception occurs, the original value stays intact.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Notes
|
||||
|
||||
!!! warning
|
||||
|
||||
Writing data to the pointee of the result yields an undefined state.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The example below shows how pointers to internal values of a JSON value can be requested. Note that no type
|
||||
conversions are made and a `#!cpp nullptr` is returned if the value and the requested pointer type does not match.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/get_ptr.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/get_ptr.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
- Extended to binary types in version 3.8.0.
|
||||
64
doc/mkdocs/docs/api/basic_json/get_ref.md
Normal file
64
doc/mkdocs/docs/api/basic_json/get_ref.md
Normal file
@@ -0,0 +1,64 @@
|
||||
# basic_json::get_ref
|
||||
|
||||
```cpp
|
||||
template<typename ReferenceType>
|
||||
ReferenceType get_ref();
|
||||
|
||||
template<typename ReferenceType>
|
||||
const ReferenceType get_ref() const;
|
||||
```
|
||||
|
||||
Implicit reference access to the internally stored JSON value. No copies are made.
|
||||
|
||||
## Template arguments
|
||||
|
||||
`ReferenceType`
|
||||
: reference type; must be a reference to [`array_t`](array_t.md), [`object_t`](object_t.md),
|
||||
[`string_t`](string_t.md), [`boolean_t`](boolean_t.md), [`number_integer_t`](number_integer_t.md), or
|
||||
[`number_unsigned_t`](number_unsigned_t.md), [`number_float_t`](number_float_t.md), or [`binary_t`](binary_t.md).
|
||||
Enforced by static assertion.
|
||||
|
||||
## Return value
|
||||
|
||||
reference to the internally stored JSON value if the requested reference type fits to the JSON value; throws
|
||||
[`type_error.303`](../../home/exceptions.md#jsonexceptiontype_error303) otherwise
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong exception safety: if an exception occurs, the original value stays intact.
|
||||
|
||||
## Exceptions
|
||||
|
||||
Throws [`type_error.303`](../../home/exceptions.md#jsonexceptiontype_error303) if the requested reference type does not
|
||||
match the stored JSON value type; example: `"incompatible ReferenceType for get_ref, actual type is binary"`.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Notes
|
||||
|
||||
!!! warning
|
||||
|
||||
Writing data to the referee of the result yields an undefined state.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The example shows several calls to `get_ref()`.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/get_ref.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/get_ref.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.1.0.
|
||||
- Extended to binary types in version 3.8.0.
|
||||
58
doc/mkdocs/docs/api/basic_json/get_to.md
Normal file
58
doc/mkdocs/docs/api/basic_json/get_to.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# basic_json::get_to
|
||||
|
||||
```cpp
|
||||
template<typename ValueType>
|
||||
ValueType& get_to(ValueType& v) const noexcept(
|
||||
noexcept(JSONSerializer<ValueType>::from_json(
|
||||
std::declval<const basic_json_t&>(), v)))
|
||||
```
|
||||
|
||||
Explicit type conversion between the JSON value and a compatible value. The value is filled into the input parameter by
|
||||
calling the `json_serializer<ValueType>` `from_json()` method.
|
||||
|
||||
The function is equivalent to executing
|
||||
```cpp
|
||||
ValueType v;
|
||||
JSONSerializer<ValueType>::from_json(*this, v);
|
||||
```
|
||||
|
||||
This overloads is chosen if:
|
||||
|
||||
- `ValueType` is not `basic_json`,
|
||||
- `json_serializer<ValueType>` has a `from_json()` method of the form `void from_json(const basic_json&, ValueType&)`
|
||||
|
||||
## Template parameters
|
||||
|
||||
`ValueType`
|
||||
: the value type to return
|
||||
|
||||
## Return value
|
||||
|
||||
the input parameter, allowing chaining calls
|
||||
|
||||
## Exceptions
|
||||
|
||||
Depends on what `json_serializer<ValueType>` `from_json()` method throws
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The example below shows several conversions from JSON values to other types. There a few things to note: (1)
|
||||
Floating-point numbers can be converted to integers, (2) A JSON array can be converted to a standard
|
||||
`#!cpp std::vector<short>`, (3) A JSON object can be converted to C++ associative containers such as
|
||||
`#cpp std::unordered_map<std::string, json>`.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/get_to.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/get_to.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 3.3.0.
|
||||
252
doc/mkdocs/docs/api/basic_json/index.md
Normal file
252
doc/mkdocs/docs/api/basic_json/index.md
Normal file
@@ -0,0 +1,252 @@
|
||||
# basic_json
|
||||
|
||||
Defined in header `<json.hpp>`
|
||||
|
||||
```cpp
|
||||
template<
|
||||
template<typename U, typename V, typename... Args> class ObjectType = std::map,
|
||||
template<typename U, typename... Args> 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<typename U> class AllocatorType = std::allocator,
|
||||
template<typename T, typename SFINAE = void> class JSONSerializer = adl_serializer,
|
||||
class BinaryType = std::vector<std::uint8_t>
|
||||
>
|
||||
class basic_json;
|
||||
```
|
||||
|
||||
## Specializations
|
||||
|
||||
- [**json**](../json.md) - default specialization
|
||||
- [**ordered_json**](../ordered_json.md) - specialization that maintains the insertion order of object keys
|
||||
|
||||
## Template parameters
|
||||
|
||||
| Template parameter | Description | Derived type |
|
||||
| -------------------- | ----------- | ------------ |
|
||||
| `ObjectType` | type for JSON objects | [`object_t`](object_t.md) |
|
||||
| `ArrayType` | type for JSON arrays | [`array_t`](array_t.md) |
|
||||
| `StringType` | type for JSON strings and object keys | [`string_t`](string_t.md) |
|
||||
| `BooleanType` | type for JSON booleans | [`boolean_t`](boolean_t.md) |
|
||||
| `NumberIntegerType` | type for JSON integer numbers | [`number_integer_t`](number_integer_t.md) |
|
||||
| `NumberUnsignedType` | type for JSON unsigned integer numbers | [`number_unsigned_t`](number_unsigned_t.md) |
|
||||
| `NumberFloatType` | type for JSON floating-point numbers | [`number_float_t`](number_float_t.md) |
|
||||
| `AllocatorType` | type of the allocator to use | |
|
||||
| `JSONSerializer` | the serializer to resolve internal calls to `to_json()` and `from_json()` | [`json_serializer`](json_serializer.md) |
|
||||
| `BinaryType` | type for binary arrays | [`binary_t`](binary_t.md) |
|
||||
|
||||
## Iterator invalidation
|
||||
|
||||
Todo
|
||||
|
||||
## Member types
|
||||
|
||||
- [**adl_serializer**](../adl_serializer.md) - the default serializer
|
||||
- [**value_t**](value_t.md) - the JSON type enumeration
|
||||
- [**json_pointer**](../json_pointer.md) - JSON Pointer implementation
|
||||
- [**json_serializer**](json_serializer.md) - type of the serializer to for conversions from/to JSON
|
||||
- [**error_handler_t**](error_handler_t.md) - type to choose behavior on decoding errors
|
||||
- [**cbor_tag_handler_t**](cbor_tag_handler_t.md) - type to choose how to handle CBOR tags
|
||||
- initializer_list_t
|
||||
- [**input_format_t**](input_format_t.md) - type to choose the format to parse
|
||||
- json_sax_t
|
||||
|
||||
### Exceptions
|
||||
|
||||
- [**exception**](exception.md) - general exception of the `basic_json` class
|
||||
- [**parse_error**](parse_error.md) - exception indicating a parse error
|
||||
- [**invalid_iterator**](invalid_iterator.md) - exception indicating errors with iterators
|
||||
- [**type_error**](type_error.md) - exception indicating executing a member function with a wrong type
|
||||
- [**out_of_range**](out_of_range.md) - exception indicating access out of the defined range
|
||||
- [**other_error**](other_error.md) - exception indicating other library errors
|
||||
|
||||
### Container types
|
||||
|
||||
| Type | Definition |
|
||||
| ------------------------ | ---------- |
|
||||
| `value_type` | `#!cpp basic_json` |
|
||||
| `reference` | `#!cpp value_type&` |
|
||||
| `const_reference` | `#!cpp const value_type&` |
|
||||
| `difference_type` | `#!cpp std::ptrdiff_t` |
|
||||
| `size_type` | `#!cpp std::size_t` |
|
||||
| `allocator_type` | `#!cpp AllocatorType<basic_json>` |
|
||||
| `pointer` | `#!cpp std::allocator_traits<allocator_type>::pointer` |
|
||||
| `const_pointer` | `#!cpp std::allocator_traits<allocator_type>::const_pointer` |
|
||||
| `iterator` | [LegacyBidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator) |
|
||||
| `const_iterator` | constant [LegacyBidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator) |
|
||||
| `reverse_iterator` | reverse iterator, derived from `iterator` |
|
||||
| `const_reverse_iterator` | reverse iterator, derived from `const_iterator` |
|
||||
| `iteration_proxy` | helper type for [`items`](items.md) function |
|
||||
|
||||
### JSON value data types
|
||||
|
||||
- [**array_t**](array_t.md) - type for arrays
|
||||
- [**binary_t**](binary_t.md) - type for binary arrays
|
||||
- [**boolean_t**](boolean_t.md) - type for booleans
|
||||
- [**number_float_t**](number_float_t.md) - type for numbers (floating-point)
|
||||
- [**number_integer_t**](number_integer_t.md) - type for numbers (integer)
|
||||
- [**number_unsigned_t**](number_unsigned_t.md) - type for numbers (unsigned)
|
||||
- [**object_comparator_t**](object_comparator_t.md) - comparator for objects
|
||||
- [**object_t**](object_t.md) - type for objects
|
||||
- [**string_t**](string_t.md) - type for strings
|
||||
|
||||
### Parser callback
|
||||
|
||||
- [**parse_event_t**](parse_event_t.md) - parser event types
|
||||
- [**parser_callback_t**](parser_callback_t.md) - per-element parser callback type
|
||||
|
||||
## Member functions
|
||||
|
||||
- [(constructor)](basic_json.md)
|
||||
- [(destructor)](~basic_json.md)
|
||||
- [**operator=**](operator=.md) - copy assignment
|
||||
- [**array**](array_t.md) (static) - explicitly create an array
|
||||
- [**binary**](binary.md) (static) - explicitly create a binary array
|
||||
- [**object**](object_t.md) (static) - explicitly create an object
|
||||
|
||||
### Object inspection
|
||||
|
||||
Functions to inspect the type of a JSON value.
|
||||
|
||||
- [**type**](type.md) - return the type of the JSON value
|
||||
- [**operator value_t**](operator_value_t.md) - return the type of the JSON value
|
||||
- [**type_name**](type_name.md) - return the type as string
|
||||
- [**is_primitive**](is_primitive.md) - return whether type is primitive
|
||||
- [**is_structured**](is_structured.md) - return whether type is structured
|
||||
- [**is_null**](is_null.md) - return whether value is null
|
||||
- [**is_boolean**](is_boolean.md) - return whether value is a boolean
|
||||
- [**is_number**](is_number.md) - return whether value is a number
|
||||
- [**is_number_integer**](is_number_integer.md) - return whether value is an integer number
|
||||
- [**is_number_unsigned**](is_number_unsigned.md) - return whether value is an unsigned integer number
|
||||
- [**is_number_float**](is_number_float.md) - return whether value is a floating-point number
|
||||
- [**is_object**](is_object.md) - return whether value is an object
|
||||
- [**is_array**](is_array.md) - return whether value is an array
|
||||
- [**is_string**](is_string.md) - return whether value is a string
|
||||
- [**is_binary**](is_binary.md) - return whether value is a binary array
|
||||
- [**is_discarded**](is_discarded.md) - return whether value is discarded
|
||||
|
||||
### Value access
|
||||
|
||||
Direct access to the stored value of a JSON value.
|
||||
|
||||
- [**get**](get.md) - get a value
|
||||
- [**get_to**](get_to.md) - get a value and write it to a destination
|
||||
- [**get_ptr**](get_ptr.md) - get a pointer value
|
||||
- [**get_ref**](get_ref.md) - get a reference value
|
||||
- [**operator ValueType**](operator_ValueType.md) - get a value
|
||||
- [**get_binary**](get_binary.md) - get a binary value
|
||||
|
||||
### Element access
|
||||
|
||||
Access to the JSON value
|
||||
|
||||
- [**at**](at.md) - access specified element with bounds checking
|
||||
- [**operator[]**](operator[].md) - access specified element
|
||||
- [**value**](value.md) - access specified object element with default value
|
||||
- [**front**](front.md) - access the first element
|
||||
- [**back**](back.md) - access the last element
|
||||
|
||||
### Lookup
|
||||
|
||||
- [**find**](find.md) - find an element in a JSON object
|
||||
- [**count**](count.md) - returns the number of occurrences of a key in a JSON object
|
||||
- [**contains**](contains.md) - check the existence of an element in a JSON object
|
||||
|
||||
### Iterators
|
||||
|
||||
- [**begin**](begin.md) - returns an iterator to the first element
|
||||
- [**cbegin**](cbegin.md) - returns a const iterator to the first element
|
||||
- [**end**](end.md) - returns an iterator to one past the last element
|
||||
- [**cend**](cend.md) - returns a const iterator to one past the last element
|
||||
- [**rbegin**](rbegin.md) - returns an iterator to the reverse-beginning
|
||||
- [**rend**](rend.md) - returns an iterator to the reverse-end
|
||||
- [**crbegin**](crbegin.md) - returns a const iterator to the reverse-beginning
|
||||
- [**crend**](crend.md) - returns a const iterator to the reverse-end
|
||||
- [**items**](items.md) - wrapper to access iterator member functions in range-based for
|
||||
|
||||
### Capacity
|
||||
|
||||
- [**empty**](empty.md) - checks whether the container is empty
|
||||
- [**size**](size.md) - returns the number of elements
|
||||
- [**max_size**](max_size.md) - returns the maximum possible number of elements
|
||||
|
||||
### Modifiers
|
||||
|
||||
- [**clear**](clear.md) - clears the contents
|
||||
- [**push_back**](push_back.md) - add a value to an array/object
|
||||
- [**operator+=**](operator+=.md) - add a value to an array/object
|
||||
- [**emplace_back**](emplace_back.md) - add a value to an array
|
||||
- [**emplace**](emplace.md) - add a value to an object if key does not exist
|
||||
- [**erase**](erase.md) - remove elements
|
||||
- [**insert**](insert.md) - inserts elements
|
||||
- [**update**](update.md) - updates a JSON object from another object, overwriting existing keys
|
||||
- swap - exchanges the values
|
||||
|
||||
### Lexicographical comparison operators
|
||||
|
||||
- [**operator==**](operator_eq.md) - comparison: equal
|
||||
- [**operator!=**](operator_ne.md) - comparison: not equal
|
||||
- [**operator<**](operator_lt.md) - comparison: less than
|
||||
- [**operator<=**](operator_le.md) - comparison: less than or equal
|
||||
- [**operator>**](operator_gt.md) - comparison: greater than
|
||||
- [**operator>=**](operator_ge.md) - comparison: greater than or equal
|
||||
|
||||
### Serialization / Dumping
|
||||
|
||||
- [**dump**](dump.md) - serialization
|
||||
- to_string - user-defined to_string function for JSON values
|
||||
|
||||
### Deserialization / Parsing
|
||||
|
||||
- [**parse**](parse.md) (static) - deserialize from a compatible input
|
||||
- [**accept**](accept.md) (static) - check if the input is valid JSON
|
||||
- [**sax_parse**](sax_parse.md) (static) - generate SAX events
|
||||
|
||||
### JSON Pointer functions
|
||||
|
||||
- [**flatten**](flatten.md) - return flattened JSON value
|
||||
- [**unflatten**](unflatten.md) - unflatten a previously flattened JSON value
|
||||
|
||||
### JSON Patch functions
|
||||
|
||||
- [**patch**](patch.md) - applies a JSON patch
|
||||
- [**diff**](diff.md) (static) - creates a diff as a JSON patch
|
||||
|
||||
### JSON Merge Patch functions
|
||||
|
||||
- [**merge_patch**](merge_patch.md) - applies a JSON Merge Patch
|
||||
|
||||
## Static functions
|
||||
|
||||
- [**meta**](meta.md) - returns version information on the library
|
||||
- [**get_allocator**](get_allocator.md) - returns the allocator associated with the container
|
||||
|
||||
### Binary formats
|
||||
|
||||
- [**from_bson**](from_bson.md) (static) - create a JSON value from an input in BSON format
|
||||
- [**from_cbor**](from_cbor.md) (static) - create a JSON value from an input in CBOR format
|
||||
- [**from_msgpack**](from_msgpack.md) (static) - create a JSON value from an input in MessagePack format
|
||||
- [**from_ubjson**](from_ubjson.md) (static) - create a JSON value from an input in UBJSON format
|
||||
- [**to_bson**](to_bson.md) (static) - create a BSON serialization of a given JSON value
|
||||
- [**to_cbor**](to_cbor.md) (static) - create a CBOR serialization of a given JSON value
|
||||
- [**to_msgpack**](to_msgpack.md) (static) - create a MessagePack serialization of a given JSON value
|
||||
- [**to_ubjson**](to_ubjson.md) (static) - create a UBJSON serialization of a given JSON value
|
||||
|
||||
## Non-member functions
|
||||
|
||||
- operator<<(std::ostream&) - serialize to stream
|
||||
- operator>>(std::istream&) - deserialize from stream
|
||||
|
||||
## Literals
|
||||
|
||||
- [**operator""_json**](operator_literal_json.md) - user-defined string literal for JSON values
|
||||
- [**operator""_json_pointer**](operator_literal_json_pointer.md) - user-defined string literal for JSON pointers
|
||||
|
||||
## Helper classes
|
||||
|
||||
- std::hash<nlohmann::json\>
|
||||
- std::less<nlohmann::value_t\>
|
||||
- std::swap<nlohmann::json\>
|
||||
32
doc/mkdocs/docs/api/basic_json/input_format_t.md
Normal file
32
doc/mkdocs/docs/api/basic_json/input_format_t.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# basic_json::input_format_t
|
||||
|
||||
```cpp
|
||||
enum class input_format_t {
|
||||
json,
|
||||
cbor,
|
||||
msgpack,
|
||||
ubjson,
|
||||
bson
|
||||
};
|
||||
```
|
||||
|
||||
This enumeration is used in the [`sax_parse`](sax_parse.md) function to choose the input format to parse:
|
||||
|
||||
json
|
||||
: JSON (JavaScript Object Notation)
|
||||
|
||||
cbor
|
||||
: CBOR (Concise Binary Object Representation)
|
||||
|
||||
msgpack
|
||||
: MessagePack
|
||||
|
||||
ubjson
|
||||
: UBJSON (Universal Binary JSON)
|
||||
|
||||
bson
|
||||
: BSON (Binary JSON)
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.2.0.
|
||||
179
doc/mkdocs/docs/api/basic_json/insert.md
Normal file
179
doc/mkdocs/docs/api/basic_json/insert.md
Normal file
@@ -0,0 +1,179 @@
|
||||
# basic_json::insert
|
||||
|
||||
```cpp
|
||||
// (1)
|
||||
iterator insert(const_iterator pos, const basic_json& val);
|
||||
iterator insert(const_iterator pos, basic_json&& val);
|
||||
|
||||
// (2)
|
||||
iterator insert(const_iterator pos, size_type cnt, const basic_json& val);
|
||||
|
||||
// (3)
|
||||
iterator insert(const_iterator pos, const_iterator first, const_iterator last);
|
||||
|
||||
// (4)
|
||||
iterator insert(const_iterator pos, initializer_list_t ilist);
|
||||
|
||||
// (5)
|
||||
void insert(const_iterator first, const_iterator last);
|
||||
```
|
||||
|
||||
1. Inserts element `val` to array before iterator `pos`.
|
||||
2. Inserts `cnt` copies of `val` to array before iterator `pos`.
|
||||
3. Inserts elements from range `[first, last)` to array before iterator `pos`.
|
||||
4. Inserts elements from initializer list `ilist` to array before iterator `pos`.
|
||||
5. Inserts elements from range `[first, last)` to object.
|
||||
|
||||
## Parameters
|
||||
|
||||
`pos` (in)
|
||||
: iterator before which the content will be inserted; may be the `end()` iterator
|
||||
|
||||
`val` (in)
|
||||
: value to insert
|
||||
|
||||
`cnt` (in)
|
||||
: number of copies of `val` to insert
|
||||
|
||||
`first` (in)
|
||||
: begin of the range of elements to insert
|
||||
|
||||
`last` (in)
|
||||
: end of the range of elements to insert
|
||||
|
||||
`ilist` (in)
|
||||
: initializer list to insert the values from
|
||||
|
||||
## Return value
|
||||
|
||||
1. iterator pointing to the inserted `val`.
|
||||
2. iterator pointing to the first element inserted, or `pos` if `#!cpp cnt==0`
|
||||
3. iterator pointing to the first element inserted, or `pos` if `#!cpp first==last`
|
||||
4. iterator pointing to the first element inserted, or `pos` if `ilist` is empty
|
||||
5. /
|
||||
|
||||
## Exceptions
|
||||
|
||||
1. The function can throw the following exceptions:
|
||||
- Throws [`type_error.309`](../../home/exceptions.md#jsonexceptiontype_error309) if called on JSON values other than
|
||||
arrays; example: `"cannot use insert() with string"`
|
||||
- Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an
|
||||
iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"`
|
||||
2. The function can throw thw following exceptions:
|
||||
- Throws [`type_error.309`](../../home/exceptions.md#jsonexceptiontype_error309) if called on JSON values other than
|
||||
arrays; example: `"cannot use insert() with string"`
|
||||
- Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an
|
||||
iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"`
|
||||
3. The function can throw thw following exceptions:
|
||||
- Throws [`type_error.309`](../../home/exceptions.md#jsonexceptiontype_error309) if called on JSON values other than
|
||||
arrays; example: `"cannot use insert() with string"`
|
||||
- Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an
|
||||
iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"`
|
||||
- Throws [`invalid_iterator.210`](../../home/exceptions.md#jsonexceptioninvalid_iterator210) if `first` and `last`
|
||||
do not belong to the same JSON value; example: `"iterators do not fit"`
|
||||
- Throws [`invalid_iterator.211`](../../home/exceptions.md#jsonexceptioninvalid_iterator211) if `first` or `last`
|
||||
are iterators into container for which insert is called; example: `"passed iterators may not belong to container"`
|
||||
4. The function can throw thw following exceptions:
|
||||
- Throws [`type_error.309`](../../home/exceptions.md#jsonexceptiontype_error309) if called on JSON values other than
|
||||
arrays; example: `"cannot use insert() with string"`
|
||||
- Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an
|
||||
iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"`
|
||||
5. The function can throw thw following exceptions:
|
||||
- Throws [`type_error.309`](../../home/exceptions.md#jsonexceptiontype_error309) if called on JSON values other than
|
||||
objects; example: `"cannot use insert() with string"`
|
||||
- Throws [`invalid_iterator.202`](../../home/exceptions.md#jsonexceptioninvalid_iterator202) if called on an
|
||||
iterator which does not belong to the current JSON value; example: `"iterator does not fit current value"`
|
||||
- Throws [`invalid_iterator.210`](../../home/exceptions.md#jsonexceptioninvalid_iterator210) if `first` and `last`
|
||||
do not belong to the same JSON value; example: `"iterators do not fit"`
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong exception safety: if an exception occurs, the original value stays intact.
|
||||
|
||||
## Complexity
|
||||
|
||||
1. Constant plus linear in the distance between `pos` and end of the container.
|
||||
2. Linear in `cnt` plus linear in the distance between `pos` and end of the container.
|
||||
3. Linear in `#!cpp std::distance(first, last)` plus linear in the distance between `pos` and end of the container.
|
||||
4. Linear in `ilist.size()` plus linear in the distance between `pos` and end of the container.
|
||||
5. Logarithmic: `O(N*log(size() + N))`, where `N` is the number of elements to insert.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The example shows how `insert()` is used.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/insert.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/insert.output"
|
||||
```
|
||||
|
||||
??? example
|
||||
|
||||
The example shows how `insert()` is used.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/insert__count.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/insert__count.output"
|
||||
```
|
||||
|
||||
??? example
|
||||
|
||||
The example shows how `insert()` is used.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/insert__range.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/insert__range.output"
|
||||
```
|
||||
|
||||
??? example
|
||||
|
||||
The example shows how `insert()` is used.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/insert__ilist.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/insert__ilist.output"
|
||||
```
|
||||
|
||||
??? example
|
||||
|
||||
The example shows how `insert()` is used.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/insert__range_object.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/insert__range_object.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
1. Added in version 1.0.0.
|
||||
2. Added in version 1.0.0.
|
||||
3. Added in version 1.0.0.
|
||||
4. Added in version 1.0.0.
|
||||
5. Added in version 3.0.0.
|
||||
59
doc/mkdocs/docs/api/basic_json/invalid_iterator.md
Normal file
59
doc/mkdocs/docs/api/basic_json/invalid_iterator.md
Normal file
@@ -0,0 +1,59 @@
|
||||
# basic_json::invalid_iterator
|
||||
|
||||
```cpp
|
||||
class invalid_iterator : public exception;
|
||||
```
|
||||
|
||||
This exception is thrown if iterators passed to a library function do not match the expected semantics.
|
||||
|
||||
Exceptions have ids 2xx.
|
||||
|
||||
```plantuml
|
||||
std::exception <|-- basic_json::exception
|
||||
basic_json::exception <|-- basic_json::parse_error
|
||||
basic_json::exception <|-- basic_json::invalid_iterator
|
||||
basic_json::exception <|-- basic_json::type_error
|
||||
basic_json::exception <|-- basic_json::out_of_range
|
||||
basic_json::exception <|-- basic_json::other_error
|
||||
|
||||
interface std::exception {}
|
||||
|
||||
class basic_json::exception {
|
||||
+ const int id
|
||||
+ const char* what() const
|
||||
}
|
||||
|
||||
class basic_json::parse_error {
|
||||
+ const std::size_t byte
|
||||
}
|
||||
|
||||
class basic_json::invalid_iterator #FFFF00 {}
|
||||
```
|
||||
|
||||
## Member functions
|
||||
|
||||
- **what** - returns explanatory string
|
||||
|
||||
## Member variables
|
||||
|
||||
- **id** - the id of the exception
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows how a `invalid_iterator` exception can be caught.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/invalid_iterator.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/invalid_iterator.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 3.0.0.
|
||||
39
doc/mkdocs/docs/api/basic_json/is_array.md
Normal file
39
doc/mkdocs/docs/api/basic_json/is_array.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# basic_json::is_array
|
||||
|
||||
```cpp
|
||||
constexpr bool is_array() const noexcept;
|
||||
```
|
||||
|
||||
This function returns `#!cpp true` if and only if the JSON value is an array.
|
||||
|
||||
## Return value
|
||||
|
||||
`#!cpp true` if type is an array, `#!cpp false` otherwise.
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this member function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code exemplifies `is_array()` for all JSON types.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/is_array.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/is_array.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
39
doc/mkdocs/docs/api/basic_json/is_binary.md
Normal file
39
doc/mkdocs/docs/api/basic_json/is_binary.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# basic_json::is_binary
|
||||
|
||||
```cpp
|
||||
constexpr bool is_binary() const noexcept;
|
||||
```
|
||||
|
||||
This function returns `#!cpp true` if and only if the JSON value is binary array.
|
||||
|
||||
## Return value
|
||||
|
||||
`#!cpp true` if type is binary, `#!cpp false` otherwise.
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this member function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code exemplifies `is_binary()` for all JSON types.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/is_binary.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/is_binary.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.8.0.
|
||||
39
doc/mkdocs/docs/api/basic_json/is_boolean.md
Normal file
39
doc/mkdocs/docs/api/basic_json/is_boolean.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# basic_json::is_boolean
|
||||
|
||||
```cpp
|
||||
constexpr bool is_boolean() const noexcept;
|
||||
```
|
||||
|
||||
This function returns `#!cpp true` if and only if the JSON value is `#!json true` or `#!json false`.
|
||||
|
||||
## Return value
|
||||
|
||||
`#!cpp true` if type is boolean, `#!cpp false` otherwise.
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this member function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code exemplifies `is_boolean()` for all JSON types.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/is_boolean.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/is_boolean.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
72
doc/mkdocs/docs/api/basic_json/is_discarded.md
Normal file
72
doc/mkdocs/docs/api/basic_json/is_discarded.md
Normal file
@@ -0,0 +1,72 @@
|
||||
# basic_json::is_discarded
|
||||
|
||||
```cpp
|
||||
constexpr bool is_discarded() const noexcept;
|
||||
```
|
||||
|
||||
This function returns `#!cpp true` for a JSON value if either:
|
||||
|
||||
- the value was discarded during parsing with a callback function (see [`parser_callback_t`](parser_callback_t.md)), or
|
||||
- the value is the result of parsing invalid JSON with parameter `allow_exceptions` set to `#!cpp false`; see
|
||||
[`parse`](parse.md) for more information.
|
||||
|
||||
## Return value
|
||||
|
||||
`#!cpp true` if type is discarded, `#!cpp false` otherwise.
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this member function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Notes
|
||||
|
||||
!!! note
|
||||
|
||||
Discarded values are never compared equal with [`operator==`](operator_eq.md). That is, checking whether a JSON
|
||||
value `j` is discarded will only work via:
|
||||
|
||||
```cpp
|
||||
j.is_discarded()
|
||||
```
|
||||
|
||||
because
|
||||
|
||||
```cpp
|
||||
j == json::value_t::discarded
|
||||
```
|
||||
|
||||
will always be `#!cpp false`.
|
||||
|
||||
!!! note
|
||||
|
||||
When a value is discarded by a callback function (see [`parser_callback_t`](parser_callback_t.md)) during parsing,
|
||||
then it is removed when it is part of a structured value. For instance, if the second value of an array is discared,
|
||||
instead of `#!json [null, discarded, false]`, the array `#!json [null, false]` is returned. Only if the top-level
|
||||
value is discarded, the return value of the `parse` call is discarded.
|
||||
|
||||
This function will always be `#!cpp false` for JSON values after parsing. That is, discarded values can only occur
|
||||
during parsing, but will be removed when inside a structured value or replaced by null in other cases.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code exemplifies `is_discarded()` for all JSON types.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/is_discarded.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/is_discarded.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
39
doc/mkdocs/docs/api/basic_json/is_null.md
Normal file
39
doc/mkdocs/docs/api/basic_json/is_null.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# basic_json::is_null
|
||||
|
||||
```cpp
|
||||
constexpr bool is_null() const noexcept;
|
||||
```
|
||||
|
||||
This function returns `#!cpp true` if and only if the JSON value is `#!json null`.
|
||||
|
||||
## Return value
|
||||
|
||||
`#!cpp true` if type is `#!json null`, `#!cpp false` otherwise.
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this member function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code exemplifies `is_null()` for all JSON types.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/is_null.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/is_null.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
50
doc/mkdocs/docs/api/basic_json/is_number.md
Normal file
50
doc/mkdocs/docs/api/basic_json/is_number.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# basic_json::is_number
|
||||
|
||||
```cpp
|
||||
constexpr bool is_number() const noexcept;
|
||||
```
|
||||
|
||||
This function returns `#!cpp true` if and only if the JSON value is a number. This includes both integer (signed and
|
||||
unsigned) and floating-point values.
|
||||
|
||||
## Return value
|
||||
|
||||
`#!cpp true` if type is number (regardless whether integer, unsigned integer or floating-type), `#!cpp false` otherwise.
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this member function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Possible implementation
|
||||
|
||||
```cpp
|
||||
constexpr bool is_number() const noexcept
|
||||
{
|
||||
return is_number_integer() || is_number_float();
|
||||
}
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code exemplifies `is_number()` for all JSON types.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/is_number.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/is_number.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
- Extended to also return `#!cpp true` for unsigned integers in 2.0.0.
|
||||
40
doc/mkdocs/docs/api/basic_json/is_number_float.md
Normal file
40
doc/mkdocs/docs/api/basic_json/is_number_float.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# basic_json::is_number_float
|
||||
|
||||
```cpp
|
||||
constexpr bool is_number_float() const noexcept;
|
||||
```
|
||||
|
||||
This function returns `#!cpp true` if and only if the JSON value is a floating-point number. This excludes signed and
|
||||
unsigned integer values.
|
||||
|
||||
## Return value
|
||||
|
||||
`#!cpp true` if type is a floating-point number, `#!cpp false` otherwise.
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this member function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code exemplifies `is_number_float()` for all JSON types.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/is_number_float.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/is_number_float.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
41
doc/mkdocs/docs/api/basic_json/is_number_integer.md
Normal file
41
doc/mkdocs/docs/api/basic_json/is_number_integer.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# basic_json::is_number_integer
|
||||
|
||||
```cpp
|
||||
constexpr bool is_number_integer() const noexcept;
|
||||
```
|
||||
|
||||
This function returns `#!cpp true` if and only if the JSON value is a signed or unsigned integer number. This excludes
|
||||
floating-point values.
|
||||
|
||||
## Return value
|
||||
|
||||
`#!cpp true` if type is an integer or unsigned integer number, `#!cpp false` otherwise.
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this member function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code exemplifies `is_number_integer()` for all JSON types.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/is_number_integer.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/is_number_integer.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
- Extended to also return `#!cpp true` for unsigned integers in 2.0.0.
|
||||
40
doc/mkdocs/docs/api/basic_json/is_number_unsigned.md
Normal file
40
doc/mkdocs/docs/api/basic_json/is_number_unsigned.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# basic_json::is_number_unsigned
|
||||
|
||||
```cpp
|
||||
constexpr bool is_number_unsigned() const noexcept;
|
||||
```
|
||||
|
||||
This function returns `#!cpp true` if and only if the JSON value is an unsigned integer number. This excludes
|
||||
floating-point and signed integer values.
|
||||
|
||||
## Return value
|
||||
|
||||
`#!cpp true` if type is an unsigned integer number, `#!cpp false` otherwise.
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this member function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code exemplifies `is_number_unsigned()` for all JSON types.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/is_number_unsigned.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/is_number_unsigned.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 2.0.0.
|
||||
39
doc/mkdocs/docs/api/basic_json/is_object.md
Normal file
39
doc/mkdocs/docs/api/basic_json/is_object.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# basic_json::is_object
|
||||
|
||||
```cpp
|
||||
constexpr bool is_object() const noexcept;
|
||||
```
|
||||
|
||||
This function returns `#!cpp true` if and only if the JSON value is an object.
|
||||
|
||||
## Return value
|
||||
|
||||
`#!cpp true` if type is an object, `#!cpp false` otherwise.
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this member function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code exemplifies `is_object()` for all JSON types.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/is_object.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/is_object.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
60
doc/mkdocs/docs/api/basic_json/is_primitive.md
Normal file
60
doc/mkdocs/docs/api/basic_json/is_primitive.md
Normal file
@@ -0,0 +1,60 @@
|
||||
# basic_json::is_primitive
|
||||
|
||||
```cpp
|
||||
constexpr bool is_primitive() const noexcept;
|
||||
```
|
||||
|
||||
This function returns `#!cpp true` if and only if the JSON type is primitive (string, number, boolean, `#!json null`,
|
||||
binary).
|
||||
|
||||
## Return value
|
||||
|
||||
`#!cpp true` if type is primitive (string, number, boolean, `#!json null`, or binary), `#!cpp false` otherwise.
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this member function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Possible implementation
|
||||
|
||||
```cpp
|
||||
constexpr bool is_primitive() const noexcept
|
||||
{
|
||||
return is_null() || is_string() || is_boolean() || is_number() || is_binary();
|
||||
}
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
The term *primitive* stems from [RFC 8259](https://tools.ietf.org/html/rfc8259):
|
||||
|
||||
> JSON can represent four primitive types (strings, numbers, booleans, and null) and two structured types (objects and
|
||||
> arrays).
|
||||
|
||||
This library extends primitive types to binary types, because binary types are roughly comparable to strings. Hence,
|
||||
`is_primitive()` returns `#!cpp true` for binary values.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code exemplifies `is_primitive()` for all JSON types.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/is_primitive.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/is_primitive.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
- Extended to return `#!cpp true` for binary types in version 3.8.0.
|
||||
39
doc/mkdocs/docs/api/basic_json/is_string.md
Normal file
39
doc/mkdocs/docs/api/basic_json/is_string.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# basic_json::is_string
|
||||
|
||||
```cpp
|
||||
constexpr bool is_string() const noexcept;
|
||||
```
|
||||
|
||||
This function returns `#!cpp true` if and only if the JSON value is a string.
|
||||
|
||||
## Return value
|
||||
|
||||
`#!cpp true` if type is a string, `#!cpp false` otherwise.
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this member function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code exemplifies `is_string()` for all JSON types.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/is_string.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/is_string.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
48
doc/mkdocs/docs/api/basic_json/is_structured.md
Normal file
48
doc/mkdocs/docs/api/basic_json/is_structured.md
Normal file
@@ -0,0 +1,48 @@
|
||||
# basic_json::is_structured
|
||||
|
||||
```cpp
|
||||
constexpr bool is_structured() const noexcept;
|
||||
```
|
||||
|
||||
This function returns `#!cpp true` if and only if the JSON type is structured (array or object).
|
||||
|
||||
## Return value
|
||||
|
||||
`#!cpp true` if type is structured (array or object), `#!cpp false` otherwise.
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this member function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Notes
|
||||
|
||||
The term *structured* stems from [RFC 8259](https://tools.ietf.org/html/rfc8259):
|
||||
|
||||
> JSON can represent four primitive types (strings, numbers, booleans, and null) and two structured types (objects and
|
||||
> arrays).
|
||||
|
||||
Note that though strings are containers in C++, they are treated as primitive values in JSON.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code exemplifies `is_structured()` for all JSON types.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/is_structured.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/is_structured.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
96
doc/mkdocs/docs/api/basic_json/items.md
Normal file
96
doc/mkdocs/docs/api/basic_json/items.md
Normal file
@@ -0,0 +1,96 @@
|
||||
# basic_json::items
|
||||
|
||||
```cpp
|
||||
iteration_proxy<iterator> items() noexcept;
|
||||
iteration_proxy<const_iterator> items() const noexcept;
|
||||
```
|
||||
|
||||
This function allows to access `iterator::key()` and `iterator::value()` during range-based for loops. In these loops, a
|
||||
reference to the JSON values is returned, so there is no access to the underlying iterator.
|
||||
|
||||
For loop without `items()` function:
|
||||
|
||||
```cpp
|
||||
for (auto it = j_object.begin(); it != j_object.end(); ++it)
|
||||
{
|
||||
std::cout << "key: " << it.key() << ", value:" << it.value() << '\n';
|
||||
}
|
||||
```
|
||||
|
||||
Range-based for loop without `items()` function:
|
||||
|
||||
```cpp
|
||||
for (auto it : j_object)
|
||||
{
|
||||
// "it" is of type json::reference and has no key() member
|
||||
std::cout << "value: " << it << '\n';
|
||||
}
|
||||
```
|
||||
|
||||
Range-based for loop with `items()` function:
|
||||
|
||||
```cpp
|
||||
for (auto& el : j_object.items())
|
||||
{
|
||||
std::cout << "key: " << el.key() << ", value:" << el.value() << '\n';
|
||||
}
|
||||
```
|
||||
|
||||
The `items()` function also allows to use
|
||||
[structured bindings](https://en.cppreference.com/w/cpp/language/structured_binding) (C++17):
|
||||
|
||||
```cpp
|
||||
for (auto& [key, val] : j_object.items())
|
||||
{
|
||||
std::cout << "key: " << key << ", value:" << val << '\n';
|
||||
}
|
||||
```
|
||||
|
||||
## Return value
|
||||
|
||||
iteration proxy object wrapping the current value with an interface to use in range-based for loops
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Notes
|
||||
|
||||
When iterating over an array, `key()` will return the index of the element as string (see example). For primitive types
|
||||
(e.g., numbers), `key()` returns an empty string.
|
||||
|
||||
!!! warning
|
||||
|
||||
Using `items()` on temporary objects is dangerous. Make sure the object's lifetime exeeds the iteration. See
|
||||
<https://github.com/nlohmann/json/issues/2040> for more information.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows an example for `items()`.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/items.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/items.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.0.0.
|
||||
- Added structured binding support in version 3.5.0.
|
||||
|
||||
!!! note
|
||||
|
||||
This function replaces the static function `iterator_wrapper` which was introduced in version 1.0.0, but has been
|
||||
deprecated in version 3.1.0. Function `iterator_wrapper` will be removed in version 4.0.0. Please replace all
|
||||
occurrences of `#!cpp iterator_wrapper(j)` with `#!cpp j.items()`.
|
||||
24
doc/mkdocs/docs/api/basic_json/json_serializer.md
Normal file
24
doc/mkdocs/docs/api/basic_json/json_serializer.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# basic_json::json_serializer
|
||||
|
||||
```cpp
|
||||
template<typename T, typename SFINAE>
|
||||
using json_serializer = JSONSerializer<T, SFINAE>;
|
||||
```
|
||||
|
||||
## Template parameters
|
||||
|
||||
`T`
|
||||
: type to convert; will be used in the `to_json`/`from_json` functions
|
||||
|
||||
`SFINAE`
|
||||
: type to add compile type checks via SFINAE; usually `#!cpp void`
|
||||
|
||||
## Notes
|
||||
|
||||
#### Default type
|
||||
|
||||
The default values for `json_serializer` is [`adl_serializer`](../adl_serializer.md).
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 2.0.0.
|
||||
58
doc/mkdocs/docs/api/basic_json/max_size.md
Normal file
58
doc/mkdocs/docs/api/basic_json/max_size.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# basic_json::max_size
|
||||
|
||||
```cpp
|
||||
size_type max_size() const noexcept;
|
||||
```
|
||||
|
||||
Returns the maximum number of elements a JSON value is able to hold due to system or library implementation limitations,
|
||||
i.e. `std::distance(begin(), end())` for the JSON value.
|
||||
|
||||
## Return value
|
||||
|
||||
The return value depends on the different types and is defined as follows:
|
||||
|
||||
Value type | return value
|
||||
----------- | -------------
|
||||
null | `0` (same as [`size()`](size.md))
|
||||
boolean | `1` (same as [`size()`](size.md))
|
||||
string | `1` (same as [`size()`](size.md))
|
||||
number | `1` (same as [`size()`](size.md))
|
||||
binary | `1` (same as [`size()`](size.md))
|
||||
object | result of function `object_t::max_size()`
|
||||
array | result of function `array_t::max_size()`
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant, as long as [`array_t`](array_t.md) and [`object_t`](object_t.md) satisfy the
|
||||
[Container](https://en.cppreference.com/w/cpp/named_req/Container) concept; that is, their `max_size()` functions have
|
||||
constant complexity.
|
||||
|
||||
## Notes
|
||||
|
||||
This function does not return the maximal length of a string stored as JSON value -- it returns the maximal number of
|
||||
string elements the JSON value can store which is `1`.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code calls `max_size()` on the different value types. Note the output is implementation specific.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/max_size.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/max_size.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
- Extended to return `1` for binary types in version 3.8.0.
|
||||
58
doc/mkdocs/docs/api/basic_json/merge_patch.md
Normal file
58
doc/mkdocs/docs/api/basic_json/merge_patch.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# basic_json::merge_patch
|
||||
|
||||
```cpp
|
||||
void merge_patch(const basic_json& apply_patch);
|
||||
```
|
||||
|
||||
The merge patch format is primarily intended for use with the HTTP PATCH method as a means of describing a set of
|
||||
modifications to a target resource's content. This function applies a merge patch to the current JSON value.
|
||||
|
||||
The function implements the following algorithm from Section 2 of
|
||||
[RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396):
|
||||
|
||||
```python
|
||||
define MergePatch(Target, Patch):
|
||||
if Patch is an Object:
|
||||
if Target is not an Object:
|
||||
Target = {} // Ignore the contents and set it to an empty Object
|
||||
for each Name/Value pair in Patch:
|
||||
if Value is null:
|
||||
if Name exists in Target:
|
||||
remove the Name/Value pair from Target
|
||||
else:
|
||||
Target[Name] = MergePatch(Target[Name], Value)
|
||||
return Target
|
||||
else:
|
||||
return Patch
|
||||
```
|
||||
|
||||
Thereby, `Target` is the current object; that is, the patch is applied to the current value.
|
||||
|
||||
## Parameters
|
||||
|
||||
`apply_patch` (in)
|
||||
: the patch to apply
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear in the lengths of `apply_patch`.
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The following code shows how a JSON Merge Patch is applied to a JSON document.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/merge_patch.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/merge_patch.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.0.0.
|
||||
48
doc/mkdocs/docs/api/basic_json/meta.md
Normal file
48
doc/mkdocs/docs/api/basic_json/meta.md
Normal file
@@ -0,0 +1,48 @@
|
||||
# basic_json::meta
|
||||
|
||||
```cpp
|
||||
static basic_json meta();
|
||||
```
|
||||
|
||||
This function returns a JSON object with information about the library, including the version number and information on
|
||||
the platform and compiler.
|
||||
|
||||
## Return value
|
||||
|
||||
JSON object holding version information
|
||||
|
||||
key | description
|
||||
----------- | ---------------
|
||||
`compiler` | Information on the used compiler. It is an object with the following keys: `c++` (the used C++ standard), `family` (the compiler family; possible values are `clang`, `icc`, `gcc`, `ilecpp`, `msvc`, `pgcpp`, `sunpro`, and `unknown`), and `version` (the compiler version).
|
||||
`copyright` | The copyright line for the library as string.
|
||||
`name` | The name of the library as string.
|
||||
`platform` | The used platform as string. Possible values are `win32`, `linux`, `apple`, `unix`, and `unknown`.
|
||||
`url` | The URL of the project as string.
|
||||
`version` | The version of the library. It is an object with the following keys: `major`, `minor`, and `patch` as defined by [Semantic Versioning](http://semver.org), and `string` (the version string).
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Example
|
||||
|
||||
The following code shows an example output of the `meta()`
|
||||
function.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/meta.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/meta.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 2.1.0.
|
||||
54
doc/mkdocs/docs/api/basic_json/number_float_t.md
Normal file
54
doc/mkdocs/docs/api/basic_json/number_float_t.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# basic_json::number_float_t
|
||||
|
||||
```cpp
|
||||
using number_float_t = NumberFloatType;
|
||||
```
|
||||
|
||||
The type used to store JSON numbers (floating-point).
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows:
|
||||
> The representation of numbers is similar to that used in most programming languages. A number is represented in base
|
||||
> 10 using decimal digits. It contains an integer component that may be prefixed with an optional minus sign, which may
|
||||
> be followed by a fraction part and/or an exponent part. Leading zeros are not allowed. (...) Numeric values that
|
||||
> cannot be represented in the grammar below (such as Infinity and NaN) are not permitted.
|
||||
|
||||
This description includes both integer and floating-point numbers. However, C++ allows more precise storage if it is
|
||||
known whether the number is a signed integer, an unsigned integer or a floating-point number. Therefore, three different
|
||||
types, [`number_integer_t`](number_integer_t.md), [`number_unsigned_t`](number_unsigned_t.md) and `number_float_t` are
|
||||
used.
|
||||
|
||||
To store floating-point numbers in C++, a type is defined by the template parameter `NumberFloatType` which chooses the
|
||||
type to use.
|
||||
|
||||
## Notes
|
||||
|
||||
#### Default type
|
||||
|
||||
With the default values for `NumberFloatType` (`double`), the default value for `number_float_t` is `#!cpp double`.
|
||||
|
||||
#### Default behavior
|
||||
|
||||
- The restrictions about leading zeros is not enforced in C++. Instead, leading zeros in floating-point literals will be
|
||||
ignored. Internally, the value will be stored as decimal number. For instance, the C++ floating-point literal `01.2`
|
||||
will be serialized to `1.2`. During deserialization, leading zeros yield an error.
|
||||
- Not-a-number (NaN) values will be serialized to `null`.
|
||||
|
||||
#### Limits
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) states:
|
||||
> This specification allows implementations to set limits on the range and precision of numbers accepted. Since software
|
||||
> that implements IEEE 754-2008 binary64 (double precision) numbers is generally available and widely used, good
|
||||
> interoperability can be achieved by implementations that expect no more precision or range than these provide, in the
|
||||
> sense that implementations will approximate JSON numbers within the expected precision.
|
||||
|
||||
This implementation does exactly follow this approach, as it uses double precision floating-point numbers. Note values
|
||||
smaller than `-1.79769313486232e+308` and values greater than `1.79769313486232e+308` will be stored as NaN internally
|
||||
and be serialized to `null`.
|
||||
|
||||
#### Storage
|
||||
|
||||
Floating-point number values are stored directly inside a `basic_json` type.
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
60
doc/mkdocs/docs/api/basic_json/number_integer_t.md
Normal file
60
doc/mkdocs/docs/api/basic_json/number_integer_t.md
Normal file
@@ -0,0 +1,60 @@
|
||||
# basic_json::number_integer_t
|
||||
|
||||
```cpp
|
||||
using number_integer_t = NumberIntegerType;
|
||||
```
|
||||
|
||||
The type used to store JSON numbers (integers).
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows:
|
||||
> The representation of numbers is similar to that used in most programming languages. A number is represented in base
|
||||
> 10 using decimal digits. It contains an integer component that may be prefixed with an optional minus sign, which may
|
||||
> be followed by a fraction part and/or an exponent part. Leading zeros are not allowed. (...) Numeric values that
|
||||
> cannot be represented in the grammar below (such as Infinity and NaN) are not permitted.
|
||||
|
||||
This description includes both integer and floating-point numbers. However, C++ allows more precise storage if it is
|
||||
known whether the number is a signed integer, an unsigned integer or a floating-point number. Therefore, three different
|
||||
types, `number_integer_t`, [`number_unsigned_t`](number_unsigned_t.md) and [`number_float_t`](number_float_t.md) are
|
||||
used.
|
||||
|
||||
To store integer numbers in C++, a type is defined by the template parameter `NumberIntegerType` which chooses the type
|
||||
to use.
|
||||
|
||||
## Notes
|
||||
|
||||
#### Default type
|
||||
|
||||
With the default values for `NumberIntegerType` (`std::int64_t`), the default value for `number_integer_t` is
|
||||
`#!cpp std::int64_t`.
|
||||
|
||||
#### Default behavior
|
||||
|
||||
- The restrictions about leading zeros is not enforced in C++. Instead, leading zeros in integer literals lead to an
|
||||
interpretation as octal number. Internally, the value will be stored as decimal number. For instance, the C++ integer
|
||||
literal `010` will be serialized to `8`. During deserialization, leading zeros yield an error.
|
||||
- Not-a-number (NaN) values will be serialized to `null`.
|
||||
|
||||
#### Limits
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) specifies:
|
||||
> An implementation may set limits on the range and precision of numbers.
|
||||
|
||||
When the default type is used, the maximal integer number that can be stored is `9223372036854775807` (INT64_MAX) and
|
||||
the minimal integer number that can be stored is `-9223372036854775808` (INT64_MIN). Integer numbers that are out of
|
||||
range will yield over/underflow when used in a constructor. During deserialization, too large or small integer numbers
|
||||
will be automatically be stored as [`number_unsigned_t`](number_unsigned_t.md) or [`number_float_t`](number_float_t.md).
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) further states:
|
||||
> Note that when such software is used, numbers that are integers and are in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are
|
||||
> interoperable in the sense that implementations will agree exactly on their numeric values.
|
||||
|
||||
As this range is a subrange of the exactly supported range [INT64_MIN, INT64_MAX], this class's integer type is
|
||||
interoperable.
|
||||
|
||||
#### Storage
|
||||
|
||||
Integer number values are stored directly inside a `basic_json` type.
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
60
doc/mkdocs/docs/api/basic_json/number_unsigned_t.md
Normal file
60
doc/mkdocs/docs/api/basic_json/number_unsigned_t.md
Normal file
@@ -0,0 +1,60 @@
|
||||
# basic_json::number_unsigned_t
|
||||
|
||||
```cpp
|
||||
using number_unsigned_t = NumberUnsignedType;
|
||||
```
|
||||
|
||||
The type used to store JSON numbers (unsigned).
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows:
|
||||
> The representation of numbers is similar to that used in most programming languages. A number is represented in base
|
||||
> 10 using decimal digits. It contains an integer component that may be prefixed with an optional minus sign, which may
|
||||
> be followed by a fraction part and/or an exponent part. Leading zeros are not allowed. (...) Numeric values that
|
||||
> cannot be represented in the grammar below (such as Infinity and NaN) are not permitted.
|
||||
|
||||
This description includes both integer and floating-point numbers. However, C++ allows more precise storage if it is
|
||||
known whether the number is a signed integer, an unsigned integer or a floating-point number. Therefore, three different
|
||||
types, [`number_integer_t`](number_integer_t.md), `number_unsigned_t` and [`number_float_t`](number_float_t.md) are
|
||||
used.
|
||||
|
||||
To store unsigned integer numbers in C++, a type is defined by the template parameter `NumberUnsignedType` which chooses
|
||||
the type to use.
|
||||
|
||||
## Notes
|
||||
|
||||
#### Default type
|
||||
|
||||
With the default values for `NumberUnsignedType` (`std::uint64_t`), the default value for `number_unsigned_t` is
|
||||
`#!cpp std::uint64_t`.
|
||||
|
||||
#### Default behavior
|
||||
|
||||
- The restrictions about leading zeros is not enforced in C++. Instead, leading zeros in integer literals lead to an
|
||||
interpretation as octal number. Internally, the value will be stored as decimal number. For instance, the C++ integer
|
||||
literal `010` will be serialized to `8`. During deserialization, leading zeros yield an error.
|
||||
- Not-a-number (NaN) values will be serialized to `null`.
|
||||
|
||||
#### Limits
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) specifies:
|
||||
> An implementation may set limits on the range and precision of numbers.
|
||||
|
||||
When the default type is used, the maximal integer number that can be stored is `18446744073709551615` (UINT64_MAX) and
|
||||
the minimal integer number that can be stored is `0`. Integer numbers that are out of range will yield over/underflow
|
||||
when used in a constructor. During deserialization, too large or small integer numbers will be automatically be stored
|
||||
as [`number_integer_t`](number_integer_t.md) or [`number_float_t`](number_float_t.md).
|
||||
|
||||
[RFC 7159](http://rfc7159.net/rfc7159) further states:
|
||||
> Note that when such software is used, numbers that are integers and are in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are
|
||||
> interoperable in the sense that implementations will agree exactly on their numeric values.
|
||||
|
||||
As this range is a subrange (when considered in conjunction with the `number_integer_t` type) of the exactly supported
|
||||
range [0, UINT64_MAX], this class's integer type is interoperable.
|
||||
|
||||
#### Storage
|
||||
|
||||
Integer number values are stored directly inside a `basic_json` type.
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 2.0.0.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user