Class JSONObjectFormatter

  • All Implemented Interfaces:
    ObjectFormatter<JSON>

    public class JSONObjectFormatter
    extends Object
    implements ObjectFormatter<JSON>
    Marshals a root instance and its persistent closure as JSON object. The closure is resolved against the persistence context that contains the root instance. The JSON format introduces a $id and $ref to address reference that pure JSON does not.
    Author:
    Pinaki Poddar
    • Constructor Detail

      • JSONObjectFormatter

        public JSONObjectFormatter()
    • Method Detail

      • encode

        public JSON encode​(Collection<OpenJPAStateManager> sms,
                           jakarta.persistence.metamodel.Metamodel model)
        Description copied from interface: ObjectFormatter
        Encode the persistent closure of the given collection of managed instances as a resource e.g a XML or HTML document or an interactive document with JavaScript or a JSON array. Exact nature of the output type is the generic parameter of this interface.
        Specified by:
        encode in interface ObjectFormatter<JSON>
        Parameters:
        sms - a collection of managed instances
        model - domain model
        Returns:
        an encoded object e.g. a XML or HTML Document or a JSON object.
      • encode

        public JSON encode​(jakarta.persistence.metamodel.Metamodel model)
        Description copied from interface: ObjectFormatter
        Encode the given domain model in to a object.
        Specified by:
        encode in interface ObjectFormatter<JSON>
        Parameters:
        model - a meta-model of managed types
        Returns:
        an encoded object e.g. a XML or HTML Document or a JSON object.