How do I serialize and deserialize Vaadin components with Gson?

Hi!

I’m trying to serialize and deserialize Vaadin components with Gson, but I’m having some troubles.
I’m serialize and deserialize with this code

public <T> void serialization(String filePath, T object) {
		try {
			BufferedWriter bw = new BufferedWriter(new FileWriter(new File(filePath)));
			String json = new Gson().toJson(object, new TypeToken<T>() {}.getType());
			bw.write(json);
			bw.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public <T> T deserialization(String filePath) {
		T object = null;
		try {
			BufferedReader br = new BufferedReader(new FileReader(new File(filePath)));
			String json = br.readLine();
			br.close();
			object = new Gson().fromJson(json, new TypeToken<T>() {}.getType());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        return object;
	}

But I got the error

java.lang.UnsupportedOperationException: Attempted to serialize java.lang.Class: com.vaadin.flow.internal.nodefeature.ElementData. Forgot to register a type adapter?

When I’m try to use it like this:

        // Deserialization - Load the past configures
		Start_Stop a = (Start_Stop) includeMethods.deserialization(START_STOP_SER);
		if(a != null) {
			System.out.println("Check1 = " + a.getCheckbox1().getValue());
			System.out.println("Temp1 = " + a.getTemperature1().getValue());
		}

		// Serialization - Load configures
		startStop.addClickListener(e-> {
			includeMethods.serialization(START_STOP_SER, this);
		});

Why? Can’t I serialize and deserialize Vaadin components with Gson?