Skip to content

Commit 95b3ac9

Browse files
committed
fix: use brace initialization for bool to json conversion
- nlohmann_json 3.12 requires explicit construction for bool values - Brace initialization syntax {value} works with explicit constructors - Applied to all bool-to-json conversions in the codebase
1 parent 7ced0d2 commit 95b3ac9

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

src/v2/pdf_resources/page_cell.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,9 @@ namespace pdflib
186186
cell.push_back(font_name); // 18
187187

188188
// Work around nlohmann_json 3.12 explicit bool constructor
189-
{
190-
nlohmann::json widget_json;
191-
widget_json = widget;
192-
cell.push_back(widget_json); // 19
193-
194-
nlohmann::json ltr_json;
195-
ltr_json = left_to_right;
196-
cell.push_back(ltr_json); // 20
197-
}
189+
// Use brace initialization to explicitly construct from bool
190+
cell.push_back(nlohmann::json{widget}); // 19
191+
cell.push_back(nlohmann::json{left_to_right}); // 20
198192
}
199193
assert(cell.size()==header.size());
200194

src/v2/pdf_sanitators/cells.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,9 @@ namespace pdflib
123123

124124
item["rendering_mode"] = cell.rendering_mode;
125125

126-
item["widget"] = cell.widget;
127-
item["left_to_right"] = cell.left_to_right;
126+
// Work around nlohmann_json 3.12 explicit bool constructor
127+
item["widget"] = nlohmann::json{cell.widget};
128+
item["left_to_right"] = nlohmann::json{cell.left_to_right};
128129
}
129130

130131
result.push_back(item);

src/v2/qpdf/to_json.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,8 @@ namespace pdflib
163163
{
164164
bool val = obj.getBoolValue();
165165
// Work around nlohmann_json 3.12 explicit bool constructor
166-
// Create json and assign bool value
167-
result = nlohmann::json();
168-
result = val;
166+
// Use brace initialization to explicitly construct from bool
167+
result = nlohmann::json{val};
169168
}
170169
else
171170
{

0 commit comments

Comments
 (0)