Convert a struct to json