Skip to content

Commit 97040d7

Browse files
committed
Merge branch 'master' of https://github.com/danielaparker/jsoncons into views
2 parents 72cd351 + 3ced402 commit 97040d7

File tree

174 files changed

+11062
-5173
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+11062
-5173
lines changed

.github/workflows/ubuntu.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ jobs:
170170
steps:
171171
- uses: actions/checkout@v4
172172
- name: Get latest CMake and ninja
173-
uses: lukka/get-cmake@v4.0.1
173+
uses: lukka/get-cmake@latest
174174
- name: cmake
175175
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DJSONCONS_BUILD_TESTS=On
176176
- name: build
@@ -189,7 +189,7 @@ jobs:
189189
steps:
190190
- uses: actions/checkout@v4
191191
- name: Get latest CMake and ninja
192-
uses: lukka/get-cmake@v4.0.1
192+
uses: lukka/get-cmake@latest
193193
- name: cmake
194194
run: cmake -S . -B build -DJSONCONS_SANITIZE=ON -DCMAKE_BUILD_TYPE=Debug -DJSONCONS_BUILD_TESTS=On
195195
- name: build
@@ -210,7 +210,7 @@ jobs:
210210
run: apt-get update ; apt-get install -y unzip git
211211
- uses: actions/checkout@v4
212212
- name: Get latest CMake and ninja
213-
uses: lukka/get-cmake@v4.0.1
213+
uses: lukka/get-cmake@latest
214214
- name: cmake
215215
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DJSONCONS_BUILD_TESTS=On
216216
- name: build
@@ -231,7 +231,7 @@ jobs:
231231
run: apt-get update ; apt-get install -y unzip git
232232
- uses: actions/checkout@v4
233233
- name: Get latest CMake and ninja
234-
uses: lukka/get-cmake@v4.0.1
234+
uses: lukka/get-cmake@latest
235235
- name: cmake
236236
run: cmake -S . -B build -DJSONCONS_SANITIZE=ON -DCMAKE_BUILD_TYPE=Debug -DJSONCONS_BUILD_TESTS=On
237237
- name: build

.github/workflows/windows.yml

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -63,55 +63,3 @@ jobs:
6363
- working-directory: build/
6464
run: ctest -C ${{ matrix.build_type }} --output-on-failure
6565

66-
vs2019:
67-
strategy:
68-
fail-fast: false
69-
matrix:
70-
build_type: [Debug, Release]
71-
architecture: [x64, x86]
72-
73-
runs-on: windows-2019
74-
75-
steps:
76-
- uses: actions/checkout@v4
77-
with:
78-
submodules: recursive
79-
80-
- run: cmake -E make_directory build
81-
82-
- shell: bash
83-
working-directory: build/
84-
run: cmake $GITHUB_WORKSPACE -G "Visual Studio 16 2019" -DJSONCONS_BUILD_TESTS=On
85-
86-
- working-directory: build/
87-
run: cmake --build . --config ${{ matrix.build_type }}
88-
89-
- working-directory: build/
90-
run: ctest -C ${{ matrix.build_type }} --output-on-failure
91-
92-
vs2019-clang:
93-
strategy:
94-
fail-fast: false
95-
matrix:
96-
build_type: [Debug, Release]
97-
architecture: [x64, x86]
98-
99-
runs-on: windows-2019
100-
101-
steps:
102-
- uses: actions/checkout@v4
103-
with:
104-
submodules: recursive
105-
106-
- run: cmake -E make_directory build
107-
108-
- shell: bash
109-
working-directory: build/
110-
run: cmake $GITHUB_WORKSPACE -G "Visual Studio 16 2019" -T ClangCL -DJSONCONS_BUILD_TESTS=On
111-
112-
- working-directory: build/
113-
run: cmake --build . --config "${{ matrix.build_type }}"
114-
115-
- working-directory: build/
116-
run: ctest --build-config "${{ matrix.build_type }}" --progress --verbose
117-

CHANGELOG.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
1.4.0 preview
22
-----
33

4-
- Enhancements
4+
- Fixed bug:
5+
6+
- Git Issue #620: Issue with JSONPath filter expression fixed through PR #621
7+
8+
- Enhancements:
59

610
- Use `std::from_chars` for chars to double conversion when supported in GCC and VC.
711
This reverts the removal of this feature in 0.170.0, because of issue [std::from_chars parsing fails tests on Windows](https://github.com/danielaparker/jsoncons/issues/405).
@@ -10,6 +14,48 @@
1014
- New `basic_json_options` member `lossless_bignum`. If `true`, reads out of range floating point numbers
1115
as strings with tag `semantic_tag::bigdec`. Defaults to true.
1216

17+
- New non-throwing versions of the decode functions that return a `std::expected`-like result,
18+
19+
- `try_decode_json`
20+
- `try_decode_csv`
21+
- `try_decode_bson`
22+
- `try_decode_cbor`
23+
- `try_decode_msgpack`
24+
- `try_decode_ubjson`
25+
26+
- New non-throwing accessor `try_as<T>()` for `basic_json` that return a `std::expected`-like result,
27+
28+
- Changes
29+
30+
- Until now, the reflection traits generated by the convenience macros `JSONCONS_ALL_MEMBER_TRAITS`
31+
etc. produced JSON (or other formats) with object names in sorted order. After this release,
32+
they will produce JSON, BSON etc. with object names in the order that they appear as macro arguments.
33+
34+
- Breaking change to staj iterator classes
35+
36+
- Classes `staj_array_view` and `staj_object_view` and corresponding factories `staj_array`
37+
and `staj_object` have been removed.
38+
- `staj_array_iterator` and `staj_object_iterator` objects are now constructed directly
39+
from a cursor rather than through one of these view objects.
40+
- Classes `staj_array_iterator` and `staj_object_iterator` now have `begin` and `end`
41+
non-member functions for range-based for loop support.
42+
43+
We don't expect this change will affect many users. In any case the change is simple, e.g.
44+
45+
auto view = staj_object<std::string,json>(cursor);
46+
for (const auto& key_val : view)
47+
{
48+
// ...
49+
}
50+
51+
becomes
52+
53+
auto iter = staj_object_iterator<std::string,json>(cursor);
54+
for (const auto& key_val : iter)
55+
{
56+
// ...
57+
}
58+
1359
1.3.2
1460
-----
1561

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.5...3.14)
1+
cmake_minimum_required(VERSION 3.15)
22

33
project(jsoncons CXX)
44

Jsoncons.natvis

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
3+
<!-- jsoncons::basic_json - basic support -->
4+
5+
<Type Name="jsoncons::key_value&lt;*,*&gt;" IncludeView="jsonconsHelper">
6+
<DisplayString> {value_} </DisplayString>
7+
<Expand>
8+
<Item Name="type">(json_storage_kind)value_.common_stor_.storage_kind_</Item>
9+
<Item Name="key">key_</Item>
10+
<Item Name="value">value_</Item>
11+
</Expand>
12+
</Type>
13+
14+
<Type Name="std::vector&lt;jsoncons::key_value&lt;*,*&gt;,*&gt;">
15+
<Intrinsic Name="size" Expression="(size_t)(_Mypair._Myval2._Mylast - _Mypair._Myval2._Myfirst)" />
16+
<DisplayString>{{ items={size()} }}</DisplayString>
17+
<Expand>
18+
<CustomListItems>
19+
<Variable Name="i" InitialValue="0"/>
20+
<Size>size()</Size>
21+
<Loop>
22+
<Item Name="{i}:{_Mypair._Myval2._Myfirst[i].key_}">_Mypair._Myval2._Myfirst[i]</Item>
23+
<Exec>i++</Exec>
24+
</Loop>
25+
</CustomListItems>
26+
</Expand>
27+
</Type>
28+
29+
<Type Name="jsoncons::basic_json&lt;*&gt;">
30+
<DisplayString Condition="common_stor_.storage_kind_ == json_storage_kind::boolean">{bool_stor_.val_}</DisplayString>
31+
<DisplayString Condition="common_stor_.storage_kind_ == json_storage_kind::int64">{int64_stor_.val_}</DisplayString>
32+
<DisplayString Condition="common_stor_.storage_kind_ == json_storage_kind::uint64">{uint64_stor_.val_}</DisplayString>
33+
<DisplayString Condition="common_stor_.storage_kind_ == json_storage_kind::float64">{double_stor_.val_}</DisplayString>
34+
<DisplayString Condition="common_stor_.storage_kind_ == json_storage_kind::half_float">{half_stor_.val_}</DisplayString>
35+
<DisplayString Condition="common_stor_.storage_kind_ == json_storage_kind::short_str">{short_string_stor_.data_,s}</DisplayString>
36+
<DisplayString Condition="common_stor_.storage_kind_ == json_storage_kind::long_str">{long_string_stor_.ptr_-&gt;p_,s}</DisplayString>
37+
<DisplayString Condition="common_stor_.storage_kind_ == json_storage_kind::byte_str">{byte_string_stor_.ptr_-&gt;p_,s}</DisplayString>
38+
<DisplayString Condition="common_stor_.storage_kind_ == json_storage_kind::array">{array_stor_.ptr_-&gt;elements_}</DisplayString>
39+
<Expand>
40+
<ArrayItems Condition="common_stor_.storage_kind_ == json_storage_kind::array">
41+
<Size>array_stor_.ptr_-&gt;elements_._Mypair._Myval2._Mylast - array_stor_.ptr_-&gt;elements_._Mypair._Myval2._Myfirst</Size>
42+
<ValuePointer>array_stor_.ptr_-&gt;elements_._Mypair._Myval2._Myfirst</ValuePointer>
43+
</ArrayItems>
44+
<ExpandedItem Condition="common_stor_.storage_kind_ == json_storage_kind::object">object_stor_.ptr_->members_</ExpandedItem>
45+
</Expand>
46+
</Type>
47+
48+
</AutoVisualizer>

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ to work with the data in a number of ways:
66

77
- As a variant-like, allocator-aware, data structure, [basic_json](doc/ref/corelib/basic_json.md)
88

9-
- As a strongly typed C++ data structure that implements [json_type_traits](doc/ref/corelib/json_type_traits.md)
9+
- As a strongly typed C++ data structure that implements jsoncons reflection traits
1010

1111
- With cursor-level access to a stream of parse events, somewhat analogous to StAX pull parsing and push serializing
1212
in the XML world.
@@ -71,7 +71,7 @@ _"really good"_ _"awesome project"_ _"very solid and very dependable"_ _"my team
7171

7272
[Get started with HealthImaging image sets and image frames using an AWS SDK](https://docs.aws.amazon.com/healthimaging/latest/devguide/example_medical-imaging_Scenario_ImageSetsAndFrames_section.html)
7373

74-
[RubyGems.org](https://rubygems.org/gems/jsoncons/versions/0.1.3?locale=en)&nbsp;&nbsp;&nbsp;[rjsoncons](https://mtmorgan.github.io/rjsoncons/)&nbsp;&nbsp;&nbsp;[CoppeliaSim](https://manual.coppeliarobotics.com/en/zmqRemoteApiOverview.htm)
74+
[RubyGems.org](https://rubygems.org/gems/jsoncons/versions/0.1.3?locale=en)&nbsp;&nbsp;&nbsp;[rjsoncons](https://mtmorgan.github.io/rjsoncons/)&nbsp;&nbsp;&nbsp;[CoppeliaSim](https://manual.coppeliarobotics.com/en/zmqRemoteApiOverview.htm)&nbsp;&nbsp;&nbsp;[reflect-cpp](https://github.com/getml/reflect-cpp?tab=readme-ov-file#serialization-formats)
7575

7676
## Get jsoncons
7777

doc/Examples.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -987,8 +987,9 @@ int main()
987987

988988
json_stream_cursor cursor(is);
989989

990-
auto view = staj_array<json>(cursor);
991-
for (const auto& j : view)
990+
//auto iter = staj_array<json>(cursor); // (until 1.4.0)
991+
auto iter = staj_array_iterator<json>(cursor); // (since 1.4.0)
992+
for (const auto& j : iter)
992993
{
993994
std::cout << pretty_print(j) << "\n";
994995
}
@@ -1024,7 +1025,7 @@ namespace ns {
10241025
{
10251026
std::string author;
10261027
std::string title;
1027-
double price;
1028+
double price{0};
10281029
};
10291030

10301031
} // namespace ns
@@ -1037,8 +1038,9 @@ int main()
10371038

10381039
json_stream_cursor cursor(is);
10391040

1040-
auto view = staj_array<ns::book>(cursor);
1041-
for (const auto& book : view)
1041+
//auto iter = staj_array<ns::book>(cursor); // (until 1.4.0)
1042+
auto iter = staj_array_iterator<ns::book>(cursor); // (since 1.4.0)
1043+
for (const auto& book : iter)
10421044
{
10431045
std::cout << book.author << ", " << book.title << "\n";
10441046
}
@@ -1084,7 +1086,7 @@ namespace ns {
10841086
BookCategory category;
10851087
std::string author;
10861088
std::string title;
1087-
double price;
1089+
double price{0};
10881090
};
10891091

10901092
// #2 Class with private member data and default constructor
@@ -1093,7 +1095,7 @@ namespace ns {
10931095
BookCategory category;
10941096
std::string author;
10951097
std::string title;
1096-
double price;
1098+
double price{0};
10971099
Book2() = default;
10981100

10991101
JSONCONS_TYPE_TRAITS_FRIEND
@@ -1331,7 +1333,7 @@ namespace ns {
13311333
BookCategory category;
13321334
std::string author;
13331335
std::string title;
1334-
double price;
1336+
double price{0};
13351337
};
13361338
13371339
// #2 Class with private member data and default constructor
@@ -1619,7 +1621,7 @@ namespace ns {
16191621
{
16201622
std::string author;
16211623
std::string title;
1622-
double price;
1624+
double price{0};
16231625
};
16241626
} // namespace ns
16251627
@@ -3485,11 +3487,11 @@ int main()
34853487
byte_string bytes2 = j["EncodedByteString"].as<byte_string>();
34863488
std::cout << "(2) " << bytes2 << "\n\n";
34873489

3488-
// Retrieve a byte string view to access the memory that's holding the byte string
3490+
// Retrieve a byte string iter to access the memory that's holding the byte string
34893491
byte_string_view bsv3 = j["ByteString"].as<byte_string_view>();
34903492
std::cout << "(3) " << bsv3 << "\n\n";
34913493

3492-
// Can't retrieve a byte string view of a text string
3494+
// Can't retrieve a byte string iter of a text string
34933495
try
34943496
{
34953497
byte_string_view bsv4 = j["EncodedByteString"].as<byte_string_view>();

doc/Reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ All core jsoncons classes and functions are in namespace `jsoncons`.
88

99
[json_type_traits](ref/corelib/json_type_traits.md)
1010
[encode_json](ref/corelib/encode_json.md)
11-
[decode_json](ref/corelib/decode_json.md)
11+
[decode_json, try_decode_json](ref/corelib/decode_json.md)
1212
[basic_json_options](ref/corelib/basic_json_options.md)
1313

1414
#### Streaming API for JSON (StAJ)

doc/Tutorials/Basics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Examples
22

3-
The examples below illustrate the use of the [json](../ref/basic_json.md) class and [json_query](../ref/jsonpath/json_query.md) function.
3+
The examples below illustrate the use of the [json](../ref/corelib/basic_json.md) class and [json_query](../ref/jsonpath/json_query.md) function.
44

55
### json construction
66

doc/ref/bson/basic_bson_cursor.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,9 @@ Graham Greene
281281

282282
### See also
283283

284-
[staj_event](../basic_staj_event.md)
284+
[staj_event](../corelib/basic_staj_event.md)
285285

286-
[staj_array_iterator](../staj_array_iterator.md)
286+
[staj_array_iterator](../corelib/staj_array_iterator.md)
287287

288-
[staj_object_iterator](../staj_object_iterator.md)
288+
[staj_object_iterator](../corelib/staj_object_iterator.md)
289289

0 commit comments

Comments
 (0)