implemented toJson and fromJson in corpus classes.