Copied!
CloneableInstantiable
Constants
public Google\ApiCore\Transport\Rest\JsonStreamDecoder::ESCAPE_CHAR = '\'
Methods
public __construct(Psr\Http\Message\StreamInterface $stream, string $decodeType, array $options = [])
 

JsonStreamDecoder is a HTTP-JSON response stream decoder for JSON-ecoded protobuf messages. The response stream must be a JSON array, where the first byte is the opening of the array (i.e. '['), and the last byte is the closing of the array (i.e. ']'). Each array item must be a JSON object and comma separated.

  • param \StreamInterface $stream The stream to decode.
  • param string $decodeType The type name of response messages to decode.
  • param array $options { An array of optional arguments.
    @type bool $ignoreUnknown
          Toggles whether or not to throw an exception when an unknown field
          is encountered in a response message. The default is true.
    @type int $readChunkSizeBytes
          The upper size limit in bytes that can be read at a time from the
          response stream. The default is 1 KB.
    
    }
  • experimental
public close()
 

Closes the underlying stream. If the stream is actively being decoded, an exception will not be thrown due to the interruption.

  • return void
public decode()
 

Begins decoding the configured response stream. It is a generator which yields messages of the given decode type from the stream until the stream completes. Throws an Exception if the stream is closed before the closing byte is read or if it encounters an error while decoding a message.

  • throws \RuntimeException
  • return \Generator
Properties
private bool $closeCalled = false
private string $decodeType
private bool $ignoreUnknown = true
private int $readChunkSize = 1024
private Psr\Http\Message\StreamInterface $stream
Methods
private _decode()
 
  • return \Generator
© 2025 Bruce Wells
Search Namespaces \ Classes
Configuration