fixed various bugs in json serializer by andrew