Clean up some logic/formatting in JSON module
auto merge of #19246 : frewsxcv/rust/json-cleanup, r=jakub-

Was looking through the JSON code and cleaned parts of it up