Removing repeated method calls inside TO_JSON method