Package org.openhab.core.io.rest
Class Stream2JSONInputStream
java.lang.Object
java.io.InputStream
org.openhab.core.io.rest.Stream2JSONInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
,JSONInputStream
@NonNullByDefault
public class Stream2JSONInputStream
extends InputStream
implements JSONInputStream
This
InputStream
will stream Stream
s as JSON one item at a time. This will reduce memory usage when
streaming large collections through the REST interface. The input stream creates one JSON representation at a time
from the top level elements of the stream. For best performance a flattened stream should be provided. Otherwise a
nested collections JSON representation will be fully transformed into memory.- Author:
- Henning Treu - Initial contribution
-
Constructor Summary
ConstructorDescriptionStream2JSONInputStream
(Stream<?> source) Creates a newStream2JSONInputStream
backed by the givenStream
source. -
Method Summary
Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Constructor Details
-
Stream2JSONInputStream
Creates a newStream2JSONInputStream
backed by the givenStream
source.- Parameters:
source
- theStream
backing this input stream. Must not be null.
-
-
Method Details
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-