Package com.restfb

Schnittstelle JsonMapper

Alle bekannten Implementierungsklassen:
DefaultJsonMapper

public interface JsonMapper
Specifies how a Facebook JSON-to-Java (and vice-versa) mapper must operate.

Note that implementors must be able to handle illegal JSON in toJavaObject(String, Class) and toJavaList(String, Class) in order to correctly process Facebook responses. For example, the Users.getLoggedInUser Legacy API call returns a value like 1240077, which is not valid JSON.

Autor:
Mark Allen
  • Verschachtelte Klassen - Übersicht

    Verschachtelte Klassen
    Modifizierer und Typ
    Schnittstelle
    Beschreibung
    static @interface 
    If you apply this annotation to a method of a type mapped by JsonMapper, it will be called after the mapping operation has been completed.
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    void
    adds a FacebookClient implementation to the mapper.
    <T> List<T>
    toJavaList(String json, Class<T> type)
    Given a JSON string, create and return a new instance of a corresponding Java List which contains elements of type type.
    <T> T
    toJavaObject(String json, Class<T> type)
    Given a JSON string, create and return a new instance of a corresponding Java object of type type.
    toJson(Object object)
    Given a Java object, create and return a JSON string that represents it.
    toJson(Object object, boolean ignoreNullValuedProperties)
    Given a Java object, create and return a JSON string that represents it.
  • Methodendetails

    • toJavaObject

      <T> T toJavaObject(String json, Class<T> type)
      Given a JSON string, create and return a new instance of a corresponding Java object of type type.

      The Java type must have a no-argument constructor.

      Typparameter:
      T - Java type to map to.
      Parameter:
      json - The JSON to be mapped to a Java type.
      type - Java type token.
      Gibt zurück:
      A Java object (of type type) representation of the JSON input.
      Löst aus:
      FacebookJsonMappingException - If an error occurs while mapping JSON to Java.
    • toJavaList

      <T> List<T> toJavaList(String json, Class<T> type)
      Given a JSON string, create and return a new instance of a corresponding Java List which contains elements of type type.

      The Java type must have a no-argument constructor.

      Typparameter:
      T - Java type to map to for each element of the list.
      Parameter:
      json - The JSON to be mapped to a Java type.
      type - Java type token.
      Gibt zurück:
      A Java object (of type List which contains elements of type type) representation of the JSON input.
      Löst aus:
      FacebookJsonMappingException - If an error occurs while mapping JSON to Java.
    • toJson

      String toJson(Object object)
      Given a Java object, create and return a JSON string that represents it.

      The object's properties will be traversed recursively, allowing for arbitrarily complex JSON generation.

      Parameter:
      object - The Java object to map to JSON. Can be a Javabean, List, or Map.
      Gibt zurück:
      A JSON string.
      Löst aus:
      FacebookJsonMappingException - If an error occurs while mapping Java to JSON.
      Seit:
      1.4
    • toJson

      String toJson(Object object, boolean ignoreNullValuedProperties)
      Given a Java object, create and return a JSON string that represents it.

      The object's properties will be traversed recursively, allowing for arbitrarily complex JSON generation.

      Parameter:
      object - The Java object to map to JSON. Can be a Javabean, List, or Map.
      ignoreNullValuedProperties - If true, no Javabean properties with null values will be included in the generated JSON.
      Gibt zurück:
      A JSON string.
      Löst aus:
      FacebookJsonMappingException - If an error occurs while mapping Java to JSON.
      Seit:
      1.6.5
    • setFacebookClient

      void setFacebookClient(FacebookClient facebookClient)
      adds a FacebookClient implementation to the mapper. This is especially useful for mapping json to Connection objects that need the client itself.
      Parameter:
      facebookClient - that is used for Connection objects