Fixes #400 - strip deeply nested $ prefixes when saving json

@davideast please review cc @jacobawenger