2

I need to serialize this particular object with flexJSON 2.0:

public class DiagramNodeDataSerializableRepresentation {

    private List<Node> nodes;
    private Map<Node, List<NodeOutput>> connections;

    public DiagramNodeDataSerializableRepresentation() {

    }

    public List<Node> getNodes() {
        return nodes;
    }

    public void setNodes(List<Node> nodes) {
        this.nodes = nodes;
    }

    public Map<Node, List<NodeOutput>> getConnections() {
        return connections;
    }

    public void setConnections(Map<Node, List<NodeOutput>> connections) {
        this.connections = connections;
    }

}

Where Node & NodeOutput are just POJOs with only some string fields. I'm got stuck with Map >. I've tried many different approaches without success. Could you help me with this ?

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332

1 Answers1

0

Using the deepSerialize method instead of the usual serialize worked for me:

    DiagramNodeDataSerializableRepresentation p = createTestData();
    JSONSerializer serializer = new JSONSerializer();
    String retval = serializer.deepSerialize( p );

This answer to a similar question will tell you all you need to know: How to serialize Map<String, List<Object>> with FlexJSON

Community
  • 1
  • 1
Capn Sparrow
  • 2,030
  • 2
  • 15
  • 32