added a version which uses the built in json serialization library