File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -475,6 +475,8 @@ public extension Lookup {
475475 return " \( rawNumber) "
476476 case . string:
477477 return rawString
478+ case . bool:
479+ return rawBool ? " true " : " false "
478480 default :
479481 return nil
480482 }
Original file line number Diff line number Diff line change @@ -559,4 +559,35 @@ struct LookupTests {
559559""" )
560560 }
561561 #endif
562+
563+ @Test ( " Test true/false to string " )
564+ func testTrueFalseToString( ) throws {
565+ let json = """
566+ {
567+ " status " : " success " ,
568+ " country " : " 新加坡 " ,
569+ " countryCode " : " SG " ,
570+ " region " : " 03 " ,
571+ " regionName " : " North West " ,
572+ " city " : " 新加坡 " ,
573+ " zip " : " 858877 " ,
574+ " timezone " : " Asia/Singapore " ,
575+ " currency " : " SGD " ,
576+ " isp " : " Alibaba (US) Technology Co., Ltd. " ,
577+ " org " : " Alibaba.com LLC " ,
578+ " as " : " AS45102 Alibaba (US) Technology Co., Ltd. " ,
579+ " proxy " : false,
580+ " hosting " : true
581+ }
582+ """
583+ let lookup = Lookup ( json)
584+ #expect( lookup. proxy. string == " false " )
585+ #expect( lookup. hosting. string == " true " )
586+
587+ #expect( lookup. proxy. int == 0 )
588+ #expect( lookup. hosting. int == 1 )
589+
590+ #expect( lookup. proxy. bool == false )
591+ #expect( lookup. hosting. bool == true )
592+ }
562593}
You can’t perform that action at this time.
0 commit comments