From aa1e0041d9b1d5965862daeda8e339c916e0b347 Mon Sep 17 00:00:00 2001 From: PxyUp Date: Thu, 1 Feb 2024 02:44:57 +0100 Subject: [PATCH] code(pkg/config) - provide flag for model field --- README.md | 2 ++ pkg/config/config.go | 1 + pkg/processor/processor.go | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4e727d2..ffe7b57 100644 --- a/README.md +++ b/README.md @@ -559,6 +559,7 @@ type Model struct { ObjectConfig *ObjectConfig `yaml:"object_config" json:"object_config"` ArrayConfig *ArrayConfig `json:"array_config" yaml:"array_config"` BaseField *BaseField `json:"base_field" yaml:"base_field"` + IsArray bool `json:"is_array" yaml:"is_array"` } ``` @@ -566,6 +567,7 @@ Config can be one of: - [ObjectConfig](#objectconfig) - configuration of object format - [ArrayConfig](#arrayconfig) - configuration of array format - [BaseField](#basefield) - configuration of single/generated field +- IsArray - bool[false] - force indicate that field is array(usable in case of [model field](#model-field) with [base field](#basefield)) Example: ```json diff --git a/pkg/config/config.go b/pkg/config/config.go index 8510462..de4eba4 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -77,6 +77,7 @@ type Model struct { ObjectConfig *ObjectConfig `yaml:"object_config" json:"object_config"` ArrayConfig *ArrayConfig `json:"array_config" yaml:"array_config"` BaseField *BaseField `json:"base_field" yaml:"base_field"` + IsArray bool `json:"is_array" yaml:"is_array"` } type ConnectorConfig struct { diff --git a/pkg/processor/processor.go b/pkg/processor/processor.go index 0b18e98..5cd865c 100644 --- a/pkg/processor/processor.go +++ b/pkg/processor/processor.go @@ -64,7 +64,7 @@ func (p *processor) Process(input builder.Jsonable) (*parser.ParseResult, error) result, err := p.engine.Get(p.model, nil, nil, input) if p.notifier != nil { isArray := false - if p.model.ArrayConfig != nil { + if p.model.ArrayConfig != nil || p.model.IsArray { isArray = true } if p.notifierCfg != nil {