@@ -194,6 +194,39 @@ public void ToYamlNode_FromIssueExample_CorrectOutput()
194194 Assert . DoesNotContain ( "'fooStringValue'" , yamlOutput ) ;
195195 }
196196
197+ [ Fact ]
198+ public void ToYamlNode_StringWithLineBreaks_PreservesLineBreaks ( )
199+ {
200+ // Arrange
201+ var json = JsonNode . Parse ( @"{
202+ ""multiline"": ""Line 1\nLine 2\nLine 3"",
203+ ""description"": ""This is a description\nwith line breaks\nin it""
204+ }" ) ;
205+
206+ // Act
207+ var yamlNode = json ! . ToYamlNode ( ) ;
208+ var yamlOutput = ConvertYamlNodeToString ( yamlNode ) ;
209+
210+ // Convert back to JSON to verify round-tripping
211+ var yamlStream = new YamlStream ( ) ;
212+ using ( var sr = new System . IO . StringReader ( yamlOutput ) )
213+ {
214+ yamlStream . Load ( sr ) ;
215+ }
216+ var jsonBack = yamlStream . Documents [ 0 ] . ToJsonNode ( ) ;
217+
218+ // Assert - line breaks should be preserved during round-trip
219+ var originalMultiline = json [ "multiline" ] ? . GetValue < string > ( ) ;
220+ var roundTripMultiline = jsonBack ? [ "multiline" ] ? . GetValue < string > ( ) ;
221+ Assert . Equal ( originalMultiline , roundTripMultiline ) ;
222+ Assert . Contains ( "\n " , roundTripMultiline ) ;
223+
224+ var originalDescription = json [ "description" ] ? . GetValue < string > ( ) ;
225+ var roundTripDescription = jsonBack ? [ "description" ] ? . GetValue < string > ( ) ;
226+ Assert . Equal ( originalDescription , roundTripDescription ) ;
227+ Assert . Contains ( "\n " , roundTripDescription ) ;
228+ }
229+
197230 private static string ConvertYamlNodeToString ( YamlNode yamlNode )
198231 {
199232 using var ms = new MemoryStream ( ) ;
0 commit comments