22using System ;
33using System . Diagnostics ;
44using System . Runtime . CompilerServices ;
5- using System . Text . Json . Nodes ;
65using Unmanaged ;
76
87namespace Serialization . JSON
@@ -150,17 +149,22 @@ public readonly T As<T>() where T : unmanaged, IJSONSerializable
150149 return value ;
151150 }
152151
153- public readonly void ToString ( Text result , ReadOnlySpan < char > indent = default , bool cr = false , bool lf = false , byte depth = 0 )
152+ public readonly void ToString ( Text result , SerializationSettings settings = default )
153+ {
154+ ToString ( result , settings , 0 ) ;
155+ }
156+
157+ internal readonly void ToString ( Text result , SerializationSettings settings , byte depth )
154158 {
155159 ThrowIfDisposed ( ) ;
156160
157161 result . Append ( '{' ) ;
158162 if ( jsonObject ->properties . Count > 0 )
159163 {
160- NewLine ( ) ;
164+ settings . NewLine ( result ) ;
161165 for ( int i = 0 ; i <= depth ; i ++ )
162166 {
163- Indent ( indent ) ;
167+ settings . Indent ( result ) ;
164168 }
165169
166170 int position = 0 ;
@@ -169,7 +173,11 @@ public readonly void ToString(Text result, ReadOnlySpan<char> indent = default,
169173 ref JSONProperty property = ref jsonObject ->properties [ position ] ;
170174 byte childDepth = depth ;
171175 childDepth ++ ;
172- property . ToString ( result , true , indent , cr , lf , childDepth ) ;
176+ result . Append ( '\" ' ) ;
177+ result . Append ( property . Name ) ;
178+ result . Append ( '\" ' ) ;
179+ result . Append ( ':' ) ;
180+ property . ToString ( result , settings , childDepth ) ;
173181 position ++ ;
174182
175183 if ( position == Count )
@@ -178,39 +186,21 @@ public readonly void ToString(Text result, ReadOnlySpan<char> indent = default,
178186 }
179187
180188 result . Append ( ',' ) ;
181- NewLine ( ) ;
189+ settings . NewLine ( result ) ;
182190 for ( int i = 0 ; i <= depth ; i ++ )
183191 {
184- Indent ( indent ) ;
192+ settings . Indent ( result ) ;
185193 }
186194 }
187195
188- NewLine ( ) ;
196+ settings . NewLine ( result ) ;
189197 for ( int i = 0 ; i < depth ; i ++ )
190198 {
191- Indent ( indent ) ;
199+ settings . Indent ( result ) ;
192200 }
193201 }
194202
195203 result . Append ( '}' ) ;
196-
197- void NewLine ( )
198- {
199- if ( cr )
200- {
201- result . Append ( '\r ' ) ;
202- }
203-
204- if ( lf )
205- {
206- result . Append ( '\n ' ) ;
207- }
208- }
209-
210- void Indent ( ReadOnlySpan < char > indent )
211- {
212- result . Append ( indent ) ;
213- }
214204 }
215205
216206 public readonly override string ToString ( )
0 commit comments