@@ -208,6 +208,8 @@ struct Sections {
208
208
{
209
209
const auto indent = std::string (current_indent, ' ' );
210
210
const auto indent_next = std::string (current_indent + 2 , ' ' );
211
+ const bool push_name{outer_type == OuterType::OBJ}; // Dictionary keys must have a name
212
+
211
213
switch (arg.m_type ) {
212
214
case RPCArg::Type::STR_HEX:
213
215
case RPCArg::Type::STR:
@@ -217,10 +219,10 @@ struct Sections {
217
219
case RPCArg::Type::BOOL: {
218
220
if (outer_type == OuterType::NAMED_ARG) return ; // Nothing more to do for non-recursive types on first recursion
219
221
auto left = indent;
220
- if (arg.m_type_str .size () != 0 && outer_type == OuterType::OBJ ) {
222
+ if (arg.m_type_str .size () != 0 && push_name ) {
221
223
left += " \" " + arg.m_name + " \" : " + arg.m_type_str .at (0 );
222
224
} else {
223
- left += outer_type == OuterType::OBJ ? arg.ToStringObj (/* oneline */ false ) : arg.ToString (/* oneline */ false );
225
+ left += push_name ? arg.ToStringObj (/* oneline */ false ) : arg.ToString (/* oneline */ false );
224
226
}
225
227
left += " ," ;
226
228
PushSection ({left, arg.ToDescriptionString ()});
@@ -229,7 +231,7 @@ struct Sections {
229
231
case RPCArg::Type::OBJ:
230
232
case RPCArg::Type::OBJ_USER_KEYS: {
231
233
const auto right = outer_type == OuterType::NAMED_ARG ? " " : arg.ToDescriptionString ();
232
- PushSection ({indent + " {" , right});
234
+ PushSection ({indent + (push_name ? " \" " + arg. m_name + " \" : " : " " ) + " {" , right});
233
235
for (const auto & arg_inner : arg.m_inner ) {
234
236
Push (arg_inner, current_indent + 2 , OuterType::OBJ);
235
237
}
@@ -241,7 +243,7 @@ struct Sections {
241
243
}
242
244
case RPCArg::Type::ARR: {
243
245
auto left = indent;
244
- left += outer_type == OuterType::OBJ ? " \" " + arg.m_name + " \" : " : " " ;
246
+ left += push_name ? " \" " + arg.m_name + " \" : " : " " ;
245
247
left += " [" ;
246
248
const auto right = outer_type == OuterType::NAMED_ARG ? " " : arg.ToDescriptionString ();
247
249
PushSection ({left, right});
0 commit comments