|
|
@@ -11,9 +11,6 @@ import (
|
|
|
"github.com/modern-go/reflect2"
|
|
|
)
|
|
|
|
|
|
-// limit maximum depth of nesting, as allowed by https://tools.ietf.org/html/rfc7159#section-9
|
|
|
-const defaultMaxDepth = 10000
|
|
|
-
|
|
|
// Config customize how the API should behave.
|
|
|
// The API is created from Config by Froze.
|
|
|
type Config struct {
|
|
|
@@ -28,7 +25,6 @@ type Config struct {
|
|
|
ValidateJsonRawMessage bool
|
|
|
ObjectFieldMustBeSimpleString bool
|
|
|
CaseSensitive bool
|
|
|
- MaxDepth int
|
|
|
}
|
|
|
|
|
|
// API the public interface of this package.
|
|
|
@@ -60,7 +56,6 @@ var ConfigCompatibleWithStandardLibrary = Config{
|
|
|
EscapeHTML: true,
|
|
|
SortMapKeys: true,
|
|
|
ValidateJsonRawMessage: true,
|
|
|
- MaxDepth: -1, // encoding/json has no max depth (stack overflow at 2581101)
|
|
|
}.Froze()
|
|
|
|
|
|
// ConfigFastest marshals float with only 6 digits precision
|
|
|
@@ -85,7 +80,6 @@ type frozenConfig struct {
|
|
|
streamPool *sync.Pool
|
|
|
iteratorPool *sync.Pool
|
|
|
caseSensitive bool
|
|
|
- maxDepth int
|
|
|
}
|
|
|
|
|
|
func (cfg *frozenConfig) initCache() {
|
|
|
@@ -133,9 +127,6 @@ func addFrozenConfigToCache(cfg Config, frozenConfig *frozenConfig) {
|
|
|
|
|
|
// Froze forge API from config
|
|
|
func (cfg Config) Froze() API {
|
|
|
- if cfg.MaxDepth == 0 {
|
|
|
- cfg.MaxDepth = defaultMaxDepth
|
|
|
- }
|
|
|
api := &frozenConfig{
|
|
|
sortMapKeys: cfg.SortMapKeys,
|
|
|
indentionStep: cfg.IndentionStep,
|
|
|
@@ -143,7 +134,6 @@ func (cfg Config) Froze() API {
|
|
|
onlyTaggedField: cfg.OnlyTaggedField,
|
|
|
disallowUnknownFields: cfg.DisallowUnknownFields,
|
|
|
caseSensitive: cfg.CaseSensitive,
|
|
|
- maxDepth: cfg.MaxDepth,
|
|
|
}
|
|
|
api.streamPool = &sync.Pool{
|
|
|
New: func() interface{} {
|