Interface JSONSerializer

  • All Known Implementing Classes:
    JacksonJSONSerializer

    public interface JSONSerializer
    JSON serializer and deserializer
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      <T> T deserialize​(byte[] json, Class<T> javaType)
      Deserialize the payload in the json parameter into the Java type specified by the javaType parameter
      <T> T deserialize​(byte[] json, String javaType)
      Deserialize the payload in the json parameter into the Java type specified by the Fully Qualified Class Name contained in the javaType parameter
      <T> T deserialize​(String json, Class<T> javaType)
      Deserialize the payload in the json parameter into the Java type specified by the javaType parameter
      <T> T deserialize​(String json, String javaType)
      Deserialize the payload in the json parameter into the Java type specified by the Fully Qualified Class Name contained in the javaType parameter
      String serialize​(Object obj)
      Serialize the object to JSON
      byte[] serializeAsBytes​(Object obj)
      Serialize the object to JSON
    • Method Detail

      • serialize

        String serialize​(Object obj)
        Serialize the object to JSON
        Parameters:
        obj - the object to serialize
        Returns:
        the serialized json payload as a String
        Throws:
        JSONSerializationException - in case the json couldn't be deserialized to the specified java type
      • serializeAsBytes

        byte[] serializeAsBytes​(Object obj)
        Serialize the object to JSON
        Parameters:
        obj - the object to serialize
        Returns:
        the serialized json payload as a byte[]
        Throws:
        JSONSerializationException - in case the json couldn't be deserialized to the specified java type
      • deserialize

        <T> T deserialize​(String json,
                          String javaType)
        Deserialize the payload in the json parameter into the Java type specified by the Fully Qualified Class Name contained in the javaType parameter
        Type Parameters:
        T - the corresponding Java type
        Parameters:
        json - the json payload
        javaType - the Fully Qualified Class Name for the Java type that the json payload should be deserialized into
        Returns:
        the deserialized json payload
        Throws:
        JSONDeserializationException - in case the json couldn't be deserialized to the specified java type
      • deserialize

        <T> T deserialize​(String json,
                          Class<T> javaType)
        Deserialize the payload in the json parameter into the Java type specified by the javaType parameter
        Type Parameters:
        T - the corresponding Java type
        Parameters:
        json - the json payload
        javaType - the Java type that the json payload should be deserialized into
        Returns:
        the deserialized json payload
        Throws:
        JSONDeserializationException - in case the json couldn't be deserialized to the specified java type
      • deserialize

        <T> T deserialize​(byte[] json,
                          String javaType)
        Deserialize the payload in the json parameter into the Java type specified by the Fully Qualified Class Name contained in the javaType parameter
        Type Parameters:
        T - the corresponding Java type
        Parameters:
        json - the json payload
        javaType - the Fully Qualified Class Name for the Java type that the json payload should be deserialized into
        Returns:
        the deserialized json payload
        Throws:
        JSONDeserializationException - in case the json couldn't be deserialized to the specified java type
      • deserialize

        <T> T deserialize​(byte[] json,
                          Class<T> javaType)
        Deserialize the payload in the json parameter into the Java type specified by the javaType parameter
        Type Parameters:
        T - the corresponding Java type
        Parameters:
        json - the json payload
        javaType - the Java type that the json payload should be deserialized into
        Returns:
        the deserialized json payload
        Throws:
        JSONDeserializationException - in case the json couldn't be deserialized to the specified java type