Package org.owasp.dependencycheck.utils
Class JsonArrayFixingInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.owasp.dependencycheck.utils.JsonArrayFixingInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class JsonArrayFixingInputStream extends java.io.InputStream
Fixes a poorly formatted jSON array such as those returned bygo list -json -m all
.Example:
{ "name1": "value" } { "name2" : "value" }
Would be transformed into:[{ "name1": "value" }, { "name2" : "value" }]
Note that this is a naive implementation and will incorrectly transform a stream if there are '}' contained within the names of values.
- Author:
- Jeremy Long
-
-
Constructor Summary
Constructors Constructor Description JsonArrayFixingInputStream(java.io.InputStream in)
Constructs a new filtering input stream used to fix a poorly formatted JSON array.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
void
close()
protected boolean
isWhiteSpace(byte c)
Tests if the byte passed in is a white space character.boolean
markSupported()
int
read()
int
read(byte[] b)
int
read(byte[] b, int off, int len)
long
skip(long n)
-
-
-
Method Detail
-
read
public int read() throws java.io.IOException
- Specified by:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] b) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException
- Overrides:
skip
in classjava.io.InputStream
- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException
- Overrides:
available
in classjava.io.InputStream
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classjava.io.InputStream
-
isWhiteSpace
protected boolean isWhiteSpace(byte c)
Tests if the byte passed in is a white space character.- Parameters:
c
- the byte representing the character to test- Returns:
true
if the byte is white space; otherwisefalse
-
-