@@ -1730,7 +1730,7 @@ namespace glz
1730
1730
}
1731
1731
else {
1732
1732
if constexpr (null_t <val_t > && Opts.skip_null_members ) {
1733
- if constexpr (always_null_t <T >)
1733
+ if constexpr (always_null_t <val_t >)
1734
1734
return ;
1735
1735
else {
1736
1736
const auto is_null = [&]() {
@@ -1823,17 +1823,27 @@ namespace glz
1823
1823
std::memset (&b[ix], Opts.indentation_char , ctx.indentation_level );
1824
1824
ix += ctx.indentation_level ;
1825
1825
}
1826
+
1827
+ using val_t = field_t <T, I>;
1826
1828
1827
1829
// MSVC requires get<I> rather than keys[I]
1828
1830
static constexpr auto key = glz::get<I>(reflect<T>::keys); // GCC 14 requires auto here
1829
- if constexpr (Opts.prettify ) {
1830
- static constexpr auto quoted_key = quoted_key_v<key, Opts.prettify >;
1831
- static constexpr auto n = quoted_key.size ();
1832
- std::memcpy (&b[ix], quoted_key.data (), n);
1833
- ix += n;
1831
+ if constexpr (always_null_t <val_t >) {
1832
+ if constexpr (I == 0 || Opts.prettify ) {
1833
+ static constexpr auto quoted_key = join_v<quoted_key_v<key, Opts.prettify >, chars<" null" >>;
1834
+ static constexpr auto n = quoted_key.size ();
1835
+ std::memcpy (&b[ix], quoted_key.data (), n);
1836
+ ix += n;
1837
+ }
1838
+ else {
1839
+ static constexpr auto quoted_key = join_v<chars<" ," >, quoted_key_v<key, Opts.prettify >, chars<" null" >>;
1840
+ static constexpr auto n = quoted_key.size ();
1841
+ std::memcpy (&b[ix], quoted_key.data (), n);
1842
+ ix += n;
1843
+ }
1834
1844
}
1835
1845
else {
1836
- if constexpr (I == 0 ) {
1846
+ if constexpr (I == 0 || Opts. prettify ) {
1837
1847
static constexpr auto quoted_key = quoted_key_v<key, Opts.prettify >;
1838
1848
static constexpr auto n = quoted_key.size ();
1839
1849
std::memcpy (&b[ix], quoted_key.data (), n);
@@ -1845,17 +1855,15 @@ namespace glz
1845
1855
std::memcpy (&b[ix], quoted_key.data (), n);
1846
1856
ix += n;
1847
1857
}
1848
- }
1849
1858
1850
- using val_t = field_t <T, I>;
1851
-
1852
- static constexpr auto check_opts = required_padding<val_t >() ? write_unchecked_on<Opts>() : Opts;
1853
- if constexpr (reflectable<T>) {
1854
- to<JSON, val_t >::template op<check_opts>(get_member (value, get<I>(t)), ctx, b, ix);
1855
- }
1856
- else {
1857
- to<JSON, val_t >::template op<check_opts>(get_member (value, get<I>(reflect<T>::values)), ctx, b,
1858
- ix);
1859
+ static constexpr auto check_opts = required_padding<val_t >() ? write_unchecked_on<Opts>() : Opts;
1860
+ if constexpr (reflectable<T>) {
1861
+ to<JSON, val_t >::template op<check_opts>(get_member (value, get<I>(t)), ctx, b, ix);
1862
+ }
1863
+ else {
1864
+ to<JSON, val_t >::template op<check_opts>(get_member (value, get<I>(reflect<T>::values)), ctx, b,
1865
+ ix);
1866
+ }
1859
1867
}
1860
1868
});
1861
1869
}
0 commit comments