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.
Parameters
Name
Description
stream
Psr\Http\Message\StreamInterface
The stream to decode.
decodeType
string
The type name of response messages to decode.
options
array
An array of optional arguments.
↳ ignoreUnknown
bool
Toggles whether or not to throw an exception when an unknown field is encountered in a response message. The default is true.
↳ readChunkSizeBytes
int
The upper size limit in bytes that can be read at a time from the response stream. The default is 1 KB.
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.
Returns
Type
Description
Generator
close
Closes the underlying stream. If the stream is actively being decoded, an
exception will not be thrown due to the interruption.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Google API Core Client - Class JsonStreamDecoder (1.36.1)\n\nVersion latestkeyboard_arrow_down\n\n- [1.36.1 (latest)](/php/docs/reference/gax/latest/Transport.Rest.JsonStreamDecoder)\n- [1.36.0](/php/docs/reference/gax/1.36.0/Transport.Rest.JsonStreamDecoder)\n- [1.35.1](/php/docs/reference/gax/1.35.1/Transport.Rest.JsonStreamDecoder) \n\nNamespace\n---------\n\nGoogle \\\\ ApiCore \\\\ Transport \\\\ Rest\n\nMethods\n-------\n\n### __construct\n\nJsonStreamDecoder is a HTTP-JSON response stream decoder for JSON-ecoded\nprotobuf messages. The response stream must be a JSON array, where the first\nbyte is the opening of the array (i.e. '\\['), and the last byte is the closing\nof the array (i.e. '\\]'). Each array item must be a JSON object and comma\nseparated.\n\n### decode\n\nBegins decoding the configured response stream. It is a generator which\nyields messages of the given decode type from the stream until the stream\ncompletes. Throws an Exception if the stream is closed before the closing\nbyte is read or if it encounters an error while decoding a message.\n\n### close\n\nCloses the underlying stream. If the stream is actively being decoded, an\nexception will not be thrown due to the interruption.\n\nConstants\n---------\n\n### ESCAPE_CHAR\n\n Value: '\\\\'"]]