Overview

The intent of this component is to provide a configurable and customized integration of JSON De-/Seriallizers using GSON, Jackson 1 and Jackson 2 APIs into Avalon/Turbine. It is written for use in Turbine but it can be used in any container compatible with Avalon's ECM container. There are three implementations

  • GSONBuilderService and
  • Jackson2MapperService
  • JacksonMapperService
All Services provide basic serialization and deserialization functions for applications.

JSON Service Component with GSON API

Role Configuration

    <role
         name="org.apache.fulcrum.json.JsonService"
        shorthand="json"
        default-class="org.apache.fulcrum.json.gson.GSONBuilderService"/>
      

Component Configuration

Item Datatype Cardinality Description
globalAdapters Complex [0|1] If not set no adapter is set. Otherwise provide for each sub element adapter the class name of the adapter and set the attribute forClass to the class name the adapter should be applied. See the configuration example below.
dateFormat String [0|*] If set changes the date format. Provided string should be in a Format acceptable to the class java.text.SimpleDateFormat.SimpleDateFormat(String). The default value is MM/dd/yyyy.

Component Configuration Example

  <json>
    <dateFormat>MM/dd/yyyy</dateFormat>
    <globalAdapters>>
      <adapter forClass="x.y.z.Class">a.b.c.d.AdapterForClassXYZ</adapter-->
    </globalAdapters>
  </json>

Usage

You get a JSON service from the service like this:

JsonService jsonService = (JsonService)TurbineServices
        .getInstance().getService(JsonService.ROLE);