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 +28
-1
lines changed
tests/ServiceStack.Text.Tests/JsonTests Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change 1- using System . Collections . Generic ;
1+ using System ;
2+ using System . Collections . Generic ;
23using System . Globalization ;
34using System . Linq ;
45using NUnit . Framework ;
@@ -205,5 +206,31 @@ public void Can_detect_dto_with_no_Version()
205206 Assert . That ( fromDto1 . Name , Is . EqualTo ( "Foo 1" ) ) ;
206207 }
207208 }
209+
210+ public class ErrorPoco
211+ {
212+ public string ErrorCode { get ; set ; }
213+ public string ErrorDescription { get ; set ; }
214+ }
215+
216+ [ Test ]
217+ public void Can_deserialize_json_with_underscores ( )
218+ {
219+ var json = "{\" error_code\" :\" anErrorCode\" ,\" error_description\" ,\" the description\" }" ;
220+
221+ var dto = json . FromJson < ErrorPoco > ( ) ;
222+
223+ Assert . That ( dto . ErrorCode , Is . Null ) ;
224+
225+ using ( JsConfig . With ( propertyConvention : PropertyConvention . Lenient ) )
226+ {
227+ dto = json . FromJson < ErrorPoco > ( ) ;
228+
229+ Assert . That ( dto . ErrorCode , Is . EqualTo ( "anErrorCode" ) ) ;
230+ Assert . That ( dto . ErrorDescription , Is . EqualTo ( "the description" ) ) ;
231+
232+ dto . PrintDump ( ) ;
233+ }
234+ }
208235 }
209236}
You can’t perform that action at this time.
0 commit comments