I’m Dave Artus, work in the Industry Solutions team, in the IBM Hursley Labs. Spend most of my time travelling Europe helping Customers use IBM software such as WebSphere Application Server and related products. I design systems, write code – mostly Java and JavaScript, and like to find ways to educate myself and others. Recently our team found Pecha Kucha to be an interesting way to share information.

Outside work I amuse myself in various ways. I play Go (djna on KGS) though these days I seem to play golf more often, play guitar and sing at Chesham Tudor Folk Club and follow Watford FC to name but a few.

2 Responses to “About”

  1. Jeff Zhou said

    Hi Dave, I notice that you have several posts about Jackson over Internet. I have encountered a difficult problem which I wonder if you may lend me a hand. The problem is as follow:

    I want to serialize a complex java class w/ hashmap arraylist.

    The first code includes a hashmap object in DataBlock.java file. The second is a test class w/ a String variable and an arraylist of the hashmap object defined in DataBlock.java (for the codes please see downbelow.)

    When I ran the code, there was such an exception:

    org.codehaus.jackson.map.JsonMappingException: No serializer found for class com.yyt.apps.json.DataBlock and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: com.yyt.apps.json.test[“data”]->java.util.ArrayList[0]).

    It seems that I need to add a serializor, but how? Thanks!
    Jeff

    The first:
    import java.util.HashMap;

    public class DataBlock {

    HashMap hm;

    public ReviewBlock(){
    hm=new HashMap();
    }

    public void add(String key, String value){
    hm.put(key, value);
    }

    public String get(String key){
    return hm.get(key);
    }

    }

    The second:
    import java.io.File;
    import java.io.IOException;
    import java.util.ArrayList;
    import org.codehaus.jackson.JsonGenerationException;
    import org.codehaus.jackson.map.JsonMappingException;
    import org.codehaus.jackson.map.ObjectMapper;

    public class test {

    private String desc;
    private ArrayList data;

    public test(){}

    public void setDesc(String desc){
    this.desc=desc;
    }

    public String getDesc(){
    return desc;
    }

    @SuppressWarnings(“unchecked”)
    public void setData(ArrayList data){
    this.data=new ArrayList();
    this.data=(ArrayList) data.clone();
    }

    public ArrayList getData(){
    return data;
    }

    public static void main(String args[]) throws JsonGenerationException, JsonMappingException, IOException {
    test test= new test();
    test.setDesc(“testexm”);

    ArrayList al=new ArrayList();
    DataBlock datablock=new DataBlock();
    for(int i=0; i<10; i++){
    datablock.add("key"+i, "value"+i);
    al.add(datablock);
    }

    test.setData(al);

    ObjectMapper mapper = new ObjectMapper();
    mapper.writeValue(new File("c:/test/test.json"), test);

    }

    }

  2. djna said

    Hi Jeff. I give an example of creating my own Serializer and Deserializer in the posting https://djna.wordpress.com/2010/04/08/json-strings-and-java-objects/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: