From du to json
Given du's  output format ...
14M     someFile
6.6M    anotherFile
576K    yetAnotherFile
0       MyEmptyFile
... you can use sed to convert into json:
Here we assume that you don't have to quote special symbols in the file names, for instance ". You can quote them by inserting sed commands like s/"/\\"/g. If you also have to deal with linebreaks inside filenames check out du -0 and sed -z.
... | sed -E '1i {
s/(.*)\t(.*)/"\2": "\1",/
$s/,$//
$a }'
Filtering du's output
Please note that du -sh *| grep [MG] | sort -r may not do what you expect. With the example files from above you would get
6.6M    anotherFile
14M     someFile
0       MyEmptyFile
- I assume you want to show only files with sizes > 1MB and < 1TB. However, grep [MG]also selects files which containMorGin their name. If the current directory contains a file named justMorGyou might even end up with justgrep Morgrep Gas the unquoted[MG]is a glob (like*) that can be expanded by bash.
 Usegrep '^[0-9.]*[MG]'to safely select files with sizes specified inMBandGB.
- With sort -ryou probably want to sort by file size. But this does not work becausesort -rsorts alphabetically, not numerically (i.e.9>11). But even with numerical sort you would end up with the wrong order, as the suffixesMandGare not interpreted (i.e.2M>1G).
 Usesort -hrto sort by file sizes.
Putting everything together
du -sh * | grep '^[0-9.]*[MG]' | sort -hr | sed -E '1i {
s/(.*)\t(.*)/"\2": "\1",/
$s/,$//
$a }'