diff --git a/source/dub/internal/vibecompat/data/json.d b/source/dub/internal/vibecompat/data/json.d index 9d2a7b6..6824d58 100644 --- a/source/dub/internal/vibecompat/data/json.d +++ b/source/dub/internal/vibecompat/data/json.d @@ -1779,24 +1779,38 @@ case Json.Type.object: dst.put('{'); bool first = true; - foreach( string k, ref const Json e; json ){ - if( e.type == Json.Type.undefined ) continue; - if( !first ) dst.put(','); - first = false; - static if (pretty) { + + static if (pretty) { + import std.algorithm.sorting : sort; + string[] keyOrder; + foreach (string key, ref const Json e; json) keyOrder ~= key; + keyOrder.sort(); + + foreach( key; keyOrder ){ + if( json[key].type == Json.Type.undefined ) continue; + if( !first ) dst.put(','); + first = false; dst.put('\n'); foreach (tab; 0 .. level+1) dst.put('\t'); + dst.put('\"'); + jsonEscape(dst, key); + dst.put(pretty ? `": ` : `":`); + writeJsonString!(R, pretty)(dst, json[key], level+1); } - dst.put('\"'); - jsonEscape(dst, k); - dst.put(pretty ? `": ` : `":`); - writeJsonString!(R, pretty)(dst, e, level+1); - } - static if (pretty) { if (json.length > 0) { dst.put('\n'); foreach (tab; 0 .. level) dst.put('\t'); } + } else { + foreach( string k, ref const Json e; json ){ + if( e.type == Json.Type.undefined ) continue; + if( !first ) dst.put(','); + first = false; + dst.put('\"'); + jsonEscape(dst, k); + dst.put(pretty ? `": ` : `":`); + writeJsonString!(R, pretty)(dst, e, level+1); + } } dst.put('}'); break; diff --git a/source/dub/version_.d b/source/dub/version_.d index 2d36105..b6836fa 100644 --- a/source/dub/version_.d +++ b/source/dub/version_.d @@ -1,2 +1,2 @@ module dub.version_; -enum dubVersion = "v1.12.0"; +enum dubVersion = "v1.12.0-21-g7060b2e";