- Forward


Naive Serialization
An Introduction with Examples in Java


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Review
Back SMYC Forward
  • 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
Back SMYC Forward
  • Possible Formats:
    • XML
    • JSON
  • 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
Back SMYC Forward
javaexamples/jaxp/Person.java
 
An Example using XML (cont.)
Back SMYC Forward
javaexamples/jaxp/Address.java
 
An Example using XML (cont.)
Back SMYC Forward
javaexamples/jaxp/PhoneNumber.java
 
An Example using XML (cont.)
Back SMYC Forward
javaexamples/jaxp/PersonDriver.java
 
An Example using JSON
Back SMYC Forward
javaexamples/jsonp/Person.java
 
An Example using JSON (cont.)
Back SMYC Forward
javaexamples/jsonp/Address.java
 
An Example using JSON (cont.)
Back SMYC Forward
javaexamples/jsonp/PhoneNumber.java
 
An Example using JSON (cont.)
Back SMYC Forward
javaexamples/jsonp/PersonDriver.java
 
Increasing the Flexibility
Back SMYC Forward
  • Possible Interfaces:
    • XMLable
    • JSONable
  • What They Add:
    • The notion that something can be converted to/from XML and/or JSON
There's Always More to Learn
Back -