org.quickconnectfamily.json
Class JSONOutputStream

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

public class JSONOutputStream
extends JSONStream

The JSONOutputStream class is used when you want to send an object as a JSON string to any type of OutputStream such as a FileOutputStream or a SocketOutputStream. If you want to generate a JSON string from an object directly use the JSONUtilities.stringify methods instead.

Attributes inherited from parent classes are also included in the JSON string.




While these examples only show two levels of depth your Objects can go to any attribute depth level. You can have any combination of Java objects as attributes.

Restrictions

The Java object from which the JSON string is being generated can not be a raw Object. I can be anything that inherits from Object. The Java object from which the JSON string is being generated can not inherit from java.awt.container.

Author:
Lee S. Barney

Constructor Summary
JSONOutputStream(java.io.OutputStream aStream)
           
 
Method Summary
 void close()
          Closes the output stream and the underlying stream
 void writeObject(java.io.Serializable aSerializableObject)
          Writes a Serializable Object to the underlying stream as a JSON string
 
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

JSONOutputStream

public JSONOutputStream(java.io.OutputStream aStream)
Parameters:
aStream - - the stream to which the JSON is to be written
Method Detail

writeObject

public void writeObject(java.io.Serializable aSerializableObject)
                 throws JSONException
Writes a Serializable Object to the underlying stream as a JSON string

Parameters:
aSerializableObject - - any Serializable object other than a raw Java Object and anything that inherits from java.awt.container
Throws:
JSONException

close

public void close()
Closes the output stream and the underlying stream