[Delivers #83075194] Fix and simplify toJSON

@mhfrantz