# HG changeset patch # User Rik # Date 1673389954 28800 # Node ID d6b208b30d4ca461eacf01114219f2cb5904fe3e # Parent baa77a716bb8b719596a4eadd51de06beda533d7# Parent b4bde1e47ddeeab60cd45af8c45f888ff7fd2991 maint: merge stable to default diff -r baa77a716bb8 -r d6b208b30d4c libinterp/corefcn/jsonencode.cc --- a/libinterp/corefcn/jsonencode.cc Sat Jan 07 11:12:28 2023 -0800 +++ b/libinterp/corefcn/jsonencode.cc Tue Jan 10 14:32:34 2023 -0800 @@ -218,7 +218,7 @@ { octave_map struct_array = obj.map_value (); octave_idx_type numel = struct_array.numel (); - bool is_array = (numel > 1); + bool is_array = (numel != 1); string_vector keys = struct_array.keys (); if (is_array) diff -r baa77a716bb8 -r d6b208b30d4c test/json/jsonencode_BIST.tst --- a/test/json/jsonencode_BIST.tst Sat Jan 07 11:12:28 2023 -0800 +++ b/test/json/jsonencode_BIST.tst Tue Jan 10 14:32:34 2023 -0800 @@ -370,6 +370,19 @@ %! obs = jsonencode (data); %! assert (isequal (obs, exp)); +%!testif HAVE_RAPIDJSON <*63622> +%! data = struct ('z', {}); +%! exp = '[]'; +%! obs = jsonencode (data); +%! assert (isequal (obs, exp)); +% +%!testif HAVE_RAPIDJSON <*63622> +%! data.a = struct ('z', {}); +%! data.b = 1; +%! exp = '{"a":[],"b":1}'; +%! obs = jsonencode (data); +%! assert (isequal (obs, exp)); + %% another big Test %!testif HAVE_RAPIDJSON %! var1 = struct ('id', {0; 1; 2}, 'name', {'Collins'; 'Hays'; 'Griffin'});