goccy / go-json

Fast JSON encoder/decoder compatible with encoding/json for Go
MIT License
3.13k stars 148 forks source link

go-json is decoding elements omitted in model #462

Closed ccaneke closed 1 year ago

ccaneke commented 1 year ago
{"value":[{"properties":{"topic":"/subscriptions/397142f1-bc93-4ec9-a16b-c21ee2a7d101/resourceGroups/ifm-dev/providers/Microsoft.EventGrid/topics/EG-WHINT-Dev-Topic","provisioningState":"Succeeded","destination":{"properties":{"resourceId":"/subscriptions/397142f1-bc93-4ec9-a16b-c21ee2a7d101/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/397142f1-bc93-4ec9-a16b-c21ee2a7d101/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/397142f1-bc93-4ec9-a16b-c21ee2a7d101/resourceGroups/ifm-dev/providers/Microsoft.EventGrid/topics/EG-WHINT-Dev-Topic","provisioningState":"Succeeded","destination":{"properties":{"resourceId":"/subscriptions/397142f1-bc93-4ec9-a16b-c21ee2a7d101/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/397142f1-bc93-4ec9-a16b-c21ee2a7d101/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"}]}

string of object unexpected end of JSON input. *json.Decoder.offset: 1378. *errors.SyntaxError.Offset: 73. Run https://go.dev/play/p/Hmr8BaiAN5i to see the offsets. it seems to fail parsing the key "enableAdvancedFilteringOnArrays" even though it is omitted in the model?

my model

type EventGridEventSubscriptionSchema struct {
    Properties struct {
        Topic             string `json:"topic"`
        ProvisioningState string `json:"provisioningState"`
        //Destination       struct {
        //  Properties struct {
        //      ResourceId string `json:"resourceId"`
        //  } `json:"properties"`
        //  EndpointType string `json:"endpointType"`
        //} `json:"destination"`
        //Filter struct {
        //  SubjectBeginsWith               string `json:"subjectBeginsWith"`
        //  SubjectEndsWith                 string `json:"subjectEndsWith"`
        //  EnableAdvancedFilteringOnArrays bool   `json:"enableAdvancedFilteringOnArrays"`
        //} `json:"filter"`
        //Labels              []interface{} `json:"labels"`
        EventDeliverySchema string `json:"eventDeliverySchema"`
        RetryPolicy         struct {
            MaxDeliveryAttempts      int `json:"maxDeliveryAttempts"`
            EventTimeToLiveInMinutes int `json:"eventTimeToLiveInMinutes"`
        } `json:"retryPolicy"`
    } `json:"properties"`

    identifier
}

type identifier struct {
    ID       string `json:"id"`
    Name     string `json:"name"`
    Location string `json:"location"`
    Type     string `json:"type"`
}