add code for serializing factory to the json format