com.ibm.streams.operator.encoding

Interface JSONEncoding<O extends java.util.Map,A extends java.util.List>

    • Method Summary

      Methods 
      Modifier and Type Method and Description
      java.lang.String encodeAsString(Tuple tuple)
      Encode all attributes for tuple into a string representation of a JSON object.
      O encodeTuple(Tuple tuple)
      Encode all attributes for tuple into a JSON object.
      O encodeTuple(Tuple tuple, O data)
      Encode all attributes for tuple as a JSON object.
      java.lang.Object getAttributeObject(Tuple tuple, Attribute attribute)
      Get an attribute value from tuple as object for a JSON object.
      java.lang.Object getAttributeObject(Tuple tuple, java.lang.String attributeName)
      Get an attribute value from tuple as an object for a JSON object.
      A newJSONArray()
      Return a new JSONObject.
      O newJSONObject()
      Return a new JSONObject.
    • Method Detail

      • getAttributeObject

        java.lang.Object getAttributeObject(Tuple tuple,
                                          Attribute attribute)
        Get an attribute value from tuple as object for a JSON object. The attribute's value is returned as a object that is an instance of Boolean, Number, String, O (JSON object) or A (JSON array).
        Type mapping to JSON values
        Type.MetaTypeJSON value type
        BOOLEANBoolean
        INT8Byte
        INT16Short
        INT32Integer
        INT64Long
        FLOAT32Float
        FLOAT64Double
        DECIMAL32, DECIMAL64, DECIMAL128java.math.BigDecimal
        UINT8, UINT16Integer (as the unsigned value)
        UINT32Long (as the unsigned value)
        UINT64java.math.BigInteger (as the unsigned value)
        RSTRING, USTRING, BSTRINGString
        ENUMString
        TUPLEO (JSON object)
        TIMESTAMPjava.math.BigDecimal (from Timestamp.getTimeAsSeconds())
        MAP, BMAP O (JSON object)
        LIST, BLIST SET, BSET A (JSON array)
        Parameters:
        tuple - Tuple to extract value from.
        attribute - Attribute description. If attribute does not represent an attribute in tuple the behavior is undefined.
        Returns:
        An object that can be put into a JSON object or array
        Throws:
        java.lang.UnsupportedOperationException - Attribute cannot be represented in JSON.
      • getAttributeObject

        java.lang.Object getAttributeObject(Tuple tuple,
                                          java.lang.String attributeName)
        Get an attribute value from tuple as an object for a JSON object.
        Parameters:
        tuple - Tuple to extract value from.
        attributeName - Attribute name.
        Returns:
        An object representing the attribute's value
        See Also:
        getAttributeObject(Tuple, Attribute)
      • newJSONObject

        O newJSONObject()
        Return a new JSONObject. Uses the no-arg constructor of O to create a new instance.
        Returns:
        A new instance of O
      • newJSONArray

        A newJSONArray()
        Return a new JSONObject. Uses the no-arg constructor of A to create a new instance.
        Returns:
        A new instance of A
      • encodeTuple

        O encodeTuple(Tuple tuple)
        Encode all attributes for tuple into a JSON object.
        Parameters:
        tuple - Tuple to be encoded.
        Returns:
        JSON object containing the attributes.
      • encodeAsString

        java.lang.String encodeAsString(Tuple tuple)
                                        throws java.io.IOException
        Encode all attributes for tuple into a string representation of a JSON object.
        Parameters:
        tuple - Tuple to be encoded
        Returns:
        String representation of a JSON object
        Throws:
        java.io.IOException