blob: 5c5e1d04e4e47a2b72375fa18ca70bcd7c2724b9 [file] [log] [blame]
Pavlin Radoslavovad008e02013-02-21 18:42:42 -08001package net.floodlightcontroller.util.serializers;
2
3import java.io.IOException;
4
5import org.codehaus.jackson.JsonGenerator;
6import org.codehaus.jackson.JsonProcessingException;
7import org.codehaus.jackson.map.JsonSerializer;
8import org.codehaus.jackson.map.SerializerProvider;
9
10import net.floodlightcontroller.util.IPv4Net;
11
12/**
13 * Serialize an IPv4Net address as a string.
14 */
15public class IPv4NetSerializer extends JsonSerializer<IPv4Net> {
16
17 @Override
18 public void serialize(IPv4Net ipv4Net, JsonGenerator jGen,
19 SerializerProvider serializer)
20 throws IOException, JsonProcessingException {
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080021 jGen.writeStartObject();
22 jGen.writeStringField("value", ipv4Net.toString());
23 jGen.writeEndObject();
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080024 }
25}