@@ -11,9 +11,6 @@ import (
1111 "github.com/modern-go/reflect2"
1212)
1313
14- // limit maximum depth of nesting, as allowed by https://tools.ietf.org/html/rfc7159#section-9
15- const defaultMaxDepth = 10000
16-
1714// Config customize how the API should behave.
1815// The API is created from Config by Froze.
1916type Config struct {
@@ -28,7 +25,6 @@ type Config struct {
2825 ValidateJsonRawMessage bool
2926 ObjectFieldMustBeSimpleString bool
3027 CaseSensitive bool
31- MaxDepth int
3228}
3329
3430// API the public interface of this package.
@@ -60,7 +56,6 @@ var ConfigCompatibleWithStandardLibrary = Config{
6056 EscapeHTML : true ,
6157 SortMapKeys : true ,
6258 ValidateJsonRawMessage : true ,
63- MaxDepth : - 1 , // encoding/json has no max depth (stack overflow at 2581101)
6459}.Froze ()
6560
6661// ConfigFastest marshals float with only 6 digits precision
@@ -85,7 +80,6 @@ type frozenConfig struct {
8580 streamPool * sync.Pool
8681 iteratorPool * sync.Pool
8782 caseSensitive bool
88- maxDepth int
8983}
9084
9185func (cfg * frozenConfig ) initCache () {
@@ -133,17 +127,13 @@ func addFrozenConfigToCache(cfg Config, frozenConfig *frozenConfig) {
133127
134128// Froze forge API from config
135129func (cfg Config ) Froze () API {
136- if cfg .MaxDepth == 0 {
137- cfg .MaxDepth = defaultMaxDepth
138- }
139130 api := & frozenConfig {
140131 sortMapKeys : cfg .SortMapKeys ,
141132 indentionStep : cfg .IndentionStep ,
142133 objectFieldMustBeSimpleString : cfg .ObjectFieldMustBeSimpleString ,
143134 onlyTaggedField : cfg .OnlyTaggedField ,
144135 disallowUnknownFields : cfg .DisallowUnknownFields ,
145136 caseSensitive : cfg .CaseSensitive ,
146- maxDepth : cfg .MaxDepth ,
147137 }
148138 api .streamPool = & sync.Pool {
149139 New : func () interface {} {
0 commit comments