separated out JSON serialization

still need to find a new home for it