Closed ccaneke closed 1 year ago
When calling Decode like this
Decode
for j.decoder.More() { if err = j.decoder.Decode(dst); err != nil { return j.count, err } }
I get the following error of type *errors.SyntaxError:
*errors.SyntaxError
expected colon after object key
When the buffer is filled and being decoded it looks like this:
Then the stream cursor is on the nul byte:
so the next n bytes are read into the stream's buffer by calling s.read():
Then s.read() returns false because of the error: http2: response body closed (Client.Timeout or context cancellation while reading body).
http2: response body closed (Client.Timeout or context cancellation while reading body)
s.cursor is at byte 58 (:) but c (nul byte 0) is returned, maybe because s.read() was false:
s.cursor
:
s.read()
Then the error occurs:
In short, the error happens because s.skipWhiteSpace() returns 0 (null) when it should return : after the key "eventDeliverySchema" is read.
s.skipWhiteSpace()
"eventDeliverySchema"
To recreate this error, decode the json array below using these steps:
j.decoder.Token()
j.decoder
*json.Decoder
go-json version: github.com/goccy/go-json v0.10.0
json:
{"value":[{"properties":{"topic":"/subscriptions/134245-21f34-21gs/resourceGroups/ifm-dev/providers/Microsoft.EventGrid/topics/EG-WHINT-Dev-Topic","provisioningState":"Succeeded","destination":{"properties":{"resourceId":"/subscriptions/134245-21f34-21gs/resourceGroups/ifm-dev/providers/Microsoft.ServiceBus/namespaces/WHINT-Dev/topics/whint-topic-test"},"endpointType":"ServiceBusTopic"},"filter":{"subjectBeginsWith":"","subjectEndsWith":"","enableAdvancedFilteringOnArrays":true},"labels":[],"eventDeliverySchema":"EventGridSchema","retryPolicy":{"maxDeliveryAttempts":30,"eventTimeToLiveInMinutes":1440}},"systemData":null,"id":"/subscriptions/134245-21f34-21gs/resourceGroups/ifm-dev/providers/Microsoft.EventGrid/topics/EG-WHINT-Dev-Topic/providers/Microsoft.EventGrid/eventSubscriptions/EG-WHINT-Dev-EventSub","name":"EG-WHINT-Dev-EventSub","type":"Microsoft.EventGrid/eventSubscriptions"},{"properties":{"topic":"/subscriptions/134245-21f34-21gs/resourceGroups/ifm-dev/providers/Microsoft.EventGrid/topics/EG-WHINT-Dev-Topic","provisioningState":"Succeeded","destination":{"properties":{"resourceId":"/subscriptions/134245-21f34-21gs/resourceGroups/ifm-dev/providers/Microsoft.ServiceBus/namespaces/WHINT-SB-DEV/queues/whint-sb-queue-dev"},"endpointType":"ServiceBusQueue"},"filter":{"subjectBeginsWith":"","subjectEndsWith":"","enableAdvancedFilteringOnArrays":true},"labels":[],"eventDeliverySchema":"EventGridSchema","retryPolicy":{"maxDeliveryAttempts":30,"eventTimeToLiveInMinutes":1440}},"systemData":null,"id":"/subscriptions/134245-21f34-21gs/resourceGroups/ifm-dev/providers/Microsoft.EventGrid/topics/EG-WHINT-Dev-Topic/providers/Microsoft.EventGrid/eventSubscriptions/EG-WHINT-Dev-EventSub-queue","name":"EG-WHINT-Dev-EventSub-queue","type":"Microsoft.EventGrid/eventSubscriptions"}]}
When calling
Decode
like thisI get the following error of type
*errors.SyntaxError
:Cause of the error:
When the buffer is filled and being decoded it looks like this:
Then the stream cursor is on the nul byte:
so the next n bytes are read into the stream's buffer by calling s.read():
Then s.read() returns false because of the error:
http2: response body closed (Client.Timeout or context cancellation while reading body)
.s.cursor
is at byte 58 (:
) but c (nul byte 0) is returned, maybe becauses.read()
was false:Then the error occurs:
In short, the error happens because
s.skipWhiteSpace()
returns 0 (null) when it should return:
after the key"eventDeliverySchema"
is read.To recreate this error, decode the json array below using these steps:
j.decoder.Token()
in a loop to skip the first n tokens (j.decoder
holds a*json.Decoder
value).go-json version: github.com/goccy/go-json v0.10.0
json: