serialize ruby object attributes to json and ruby hashes