restore json_compat patches

got lost in a rebase on top of dan's changes