Replacing all _json(self) to serialize(self, purpose=None) #3895

Review ID - 2733001