try
{
JsonGenerator jg = new JsonFactory().createGenerator(out, JsonEncoding.UTF8);
ObjectMapper objectMapper = new ObjectMapper();
SimpleModule specModule = new SimpleModule("SpecModule", Version.unknownVersion());
specModule.addSerializer(LinkPhase.class, new LinkPhaseSerializer());
specModule.addSerializer(FunctionPhase.class, new FunctionPhaseSerializer());
specModule.addSerializer(BucketInput.class, new BucketInputSerializer());
specModule.addSerializer(SearchInput.class, new SearchInputSerializer());
specModule.addSerializer(BucketKeyInput.class, new BucketKeyInputSerializer());
specModule.addSerializer(IndexInput.class, new IndexInputSerializer());
objectMapper.registerModule(specModule);
jg.setCodec(objectMapper);
List<MapReducePhase> phases = spec.getPhases();