Small improvement for json PrettyEncoder
auto merge of #14932 : Sawyer47/rust/json-smallfix, r=huonw