Class JSONObjectWriter<T extends net.minidev.json.JSONAware>

  • All Implemented Interfaces:
    Consumer<T>

    public class JSONObjectWriter<T extends net.minidev.json.JSONAware>
    extends Object
    implements Consumer<T>
    JSON object writer for JAX-RS result streaming.
    • Constructor Detail

      • JSONObjectWriter

        public JSONObjectWriter​(Writer writer,
                                KeyExtractor<T> keyExtractor)
        Creates a new JSON object writer.
        Parameters:
        writer - Writer for the JSON object. Must not be null.
        keyExtractor - Extracts or determines a JSON object key from the appended elements. Must not be null.
    • Method Detail

      • writeStart

        public void writeStart()
        Writes out the opening '{' of the JSON object.
      • accept

        public void accept​(T element)
        Specified by:
        accept in interface Consumer<T extends net.minidev.json.JSONAware>
      • writeEnd

        public void writeEnd()
        Writes out the closing '}' of the JSON object and closes the writer.