This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
tests/ServiceStack.Text.Tests Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -349,5 +349,31 @@ public void Can_deserialize_Inherited_JSON_Object()
349349
350350 public class InheritedJsonObject : JsonObject { }
351351
352+ [ Test ]
353+ public void Does_escape_string_values ( )
354+ {
355+ var json = JsonObject . Parse ( "{\" text\" :\" line\n break\" }" ) ;
356+ Assert . That ( json [ "text" ] , Is . EqualTo ( "line\n break" ) ) ;
357+
358+ json = JsonObject . Parse ( "{\" a\" :{\" text\" :\" line\n break\" }}" ) ;
359+ var a = json . Object ( "a" ) ;
360+ Assert . That ( a [ "text" ] , Is . EqualTo ( "line\n break" ) ) ;
361+ }
362+
363+ public class JsonObjectWrapper
364+ {
365+ public JsonObject Prop { get ; set ; }
366+ }
367+
368+ [ Test ]
369+ public void Does_escape_strings_in_JsonObject_DTO ( )
370+ {
371+ var dto = "{\" Prop\" :{\" text\" :\" line\n break\" }}" . FromJson < JsonObjectWrapper > ( ) ;
372+ Assert . That ( dto . Prop [ "text" ] , Is . EqualTo ( "line\n break" ) ) ;
373+
374+ dto = "{\" Prop\" :{\" a\" :{\" text\" :\" line\n break\" }}}" . FromJson < JsonObjectWrapper > ( ) ;
375+ var a = dto . Prop . Object ( "a" ) ;
376+ Assert . That ( a [ "text" ] , Is . EqualTo ( "line\n break" ) ) ;
377+ }
352378 }
353379}
You can’t perform that action at this time.
0 commit comments