Naive Serialization
An Introduction with Examples in Java
|
Prof. David Bernstein
James Madison University
|
|
Computer Science Department
|
bernstdh@jmu.edu
|
Review
-
Serialization:
- The process of creating a "frozen"
representation of a "live" (i.e., in-memory) object
- "Naive" Approaches:
- Agnore the complications introduced by references
Creating "Naive" Representations
- Possible Formats:
- What's Needed:
- Method(s) to create a
String
representation
in the chosen format
- Factory method(s) to create an object from a
String
representation in the chosen format
An Example using XML
javaexamples/jaxp/Person.java
An Example using XML (cont.)
javaexamples/jaxp/Address.java
An Example using XML (cont.)
javaexamples/jaxp/PhoneNumber.java
An Example using XML (cont.)
javaexamples/jaxp/PersonDriver.java
An Example using JSON
javaexamples/jsonp/Person.java
An Example using JSON (cont.)
javaexamples/jsonp/Address.java
An Example using JSON (cont.)
javaexamples/jsonp/PhoneNumber.java
An Example using JSON (cont.)
javaexamples/jsonp/PersonDriver.java
Increasing the Flexibility
- Possible Interfaces:
- What They Add:
- The notion that something can be converted to/from XML and/or
JSON
There's Always More to Learn