Add toJSON and fromJSON functions to allow serialization of the filter