1 package de.juplo.facebook;
3 import java.io.IOException;
4 import java.util.Map.Entry;
6 import com.fasterxml.jackson.core.JsonGenerator;
7 import com.fasterxml.jackson.core.JsonProcessingException;
8 import com.fasterxml.jackson.databind.SerializerProvider;
9 import com.fasterxml.jackson.databind.ser.std.StdSerializer;
12 * @author Brian Clozel
15 public class GraphApiExceptionJackson2Serializer extends StdSerializer<GraphApiException> {
17 public GraphApiExceptionJackson2Serializer() {
18 super(GraphApiException.class);
22 public void serialize(GraphApiException value, JsonGenerator jgen, SerializerProvider provider) throws IOException,
23 JsonProcessingException {
24 jgen.writeStartObject();
25 jgen.writeStringField("error", value.getOAuth2ErrorCode());
26 jgen.writeStringField("error_description", value.getMessage());
27 if (value.getAdditionalInformation()!=null) {
28 for (Entry<String, String> entry : value.getAdditionalInformation().entrySet()) {
29 String key = entry.getKey();
30 String add = entry.getValue();
31 jgen.writeStringField(key, add);
34 jgen.writeEndObject();