Write toJSON methods for StoryElement.