is serialization in java recomended ? code example

Example 1: what is serialization in java

Serialization; when we MAP a Java object to API JSON
format (CONVERT JAVA OBJECT TO JSON);

Deserialization; API JSON/XML ^ MAP it to Java Object
(JSON TO JAVA OBJECT)

Example 2: serialization in java

Serialization; when we MAP a Java object to API JSON
format (CONVERT JAVA OBJECT TO JSON);

Deserialization; API JSON/XML ^ MAP it to Java Object
(JSON TO JAVA OBJECT)
Serialization: POJO to JSON (or string, byte array) 
when we MAP a Java object to API JSON format (Java to JSON)
Car car = new Car(); car.setMake(Toyota); 
car.setModel(Camry); given().body(car).when().post(uri)
De-Serialization: JSON to POJO 
( API JSON/XML → MAP it to Java Object (JSON TO JAVAOBJECT)
Car car2 = new Car(); car2=when().get(uri).body.as(car.class); 
 car.setMake(Toyota); car.setModel(Camry);

Tags:

Java Example