org.quickconnectfamily.json
Class JSONInputStream

java.lang.Object
  extended by org.quickconnectfamily.json.JSONStream
      extended by org.quickconnectfamily.json.JSONInputStream

public class JSONInputStream
extends JSONStream

The JSONInputStream class is used when you want to read JSON from any type of InputStream such as a FileInputStream or a SocketInputStream. If you want to convert JSON string to the appropriate Object and Array representations use the JSONUtilities.parse methods instead.

When your JSON is being parsed any JSON objects that it finds will be converted to HashMaps and any arrays found will be converted to ArrayLists. All keys and values in the HashMaps generated are Strings and all values in the ArrayLists generated are Strings.




While these examples only show two levels of depth your JSON string can go to any depth level. You can have any combination of arrays, objects, sub-arrays, and sub-objects.

Author:
Lee S. Barney

Constructor Summary
JSONInputStream(java.io.InputStream theByteStream)
           
 
Method Summary
 void close()
          Closes the stream used.
 java.lang.Object readObject()
          Reads a HashMap or ArrayList from the underlying stream
 
Methods inherited from class org.quickconnectfamily.json.JSONStream
setProtector
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSONInputStream

public JSONInputStream(java.io.InputStream theByteStream)
Parameters:
theByteStream - - the stream from which the JSON is to be read.
Method Detail

readObject

public java.lang.Object readObject()
                            throws JSONException
Reads a HashMap or ArrayList from the underlying stream

Returns:
an Object of type HashMap if the JSON being read is an object or of type ArrayList if the JSON being read is an array.
Throws:
JSONException

close

public void close()
           throws java.io.IOException
Closes the stream used.

Throws:
java.io.IOException