Contents

writeJSONObject(_:to:options:error:)

Writes a given JSON object to a stream.

Declaration

class func writeJSONObject(_ obj: Any, to stream: OutputStream, options opt: JSONSerialization.WritingOptions = [], error: NSErrorPointer) -> Int

Parameters

  • obj:

    The object to write to stream.

  • stream:

    The stream to which to write.

    The stream should be open and configured.

  • opt:

    Options for writing the JSON data.

    See Writingoptions for possible values.

  • error:

    If an error occurs, upon return contains an NSError object with code Nspropertylistwriteinvaliderror Swift.var that describes the problem.

Return Value

The number of bytes written to the stream, or 0 if an error occurs.

See Also

Creating JSON Data