Mapping between Representations:

    Assume we have a class defined as follows:

    We can map a JSON object {"name" : "Kermit"} to an instance of Customer as follows:

    Mapping Java to JSON:

    You can also map Java primitives like boolean or number values to the corresponding JSON values. For example, JSON(true) maps to the JSON constant of the boolean value true. However, note that String values are not converted but are interpreted as JSON input (see . For example, raises an exception because "a String" lacks additional escaped quotes and is no valid JSON. Nevertheless, a list of String values is properly converted to a JSON array of String values.

    Mapping to Generic Types:

    Assume we have a list of customers that we would declare as List<Customer> in Java. For mapping a JSON array [{"name" : "Kermit"}, {"name" : "Hugo"}] to such a list, calling mapTo(ArrayList.class) is not sufficient as Jackson cannot tell of which type the array’s elements are. This case can be handled by providing mapTo with a canonical type string, following Jackson’s conventions:

    Mapping to Polymorphic Types:

    Assuming that Car is an interface with various implementations, such as StationWagon or , Jackson cannot tell which implementation to use based solely on the static structure of Customer. In these cases, Jackson relies on type information that is part of the JSON. See the Jackson documentation for the various options Jackson offers to configure type serialization and deserialization. You can configure these options in Spin as described in the .