@@ -42,38 +42,23 @@ pub use validators::{validate_core_schema, PySome, SchemaValidator};
4242
4343use crate :: input:: Input ;
4444
45- #[ derive( FromPyObject ) ]
46- pub enum CacheStringsArg {
47- Bool ( bool ) ,
48- Literal ( StringCacheMode ) ,
49- }
50-
51- #[ pyfunction( signature = ( data, * , allow_inf_nan=true , cache_strings=CacheStringsArg :: Bool ( true ) , allow_partial=false ) ) ]
45+ #[ pyfunction( signature = ( data, * , allow_inf_nan=true , cache_strings=StringCacheMode :: All , allow_partial=PartialMode :: Off ) ) ]
5246pub fn from_json < ' py > (
5347 py : Python < ' py > ,
5448 data : & Bound < ' _ , PyAny > ,
5549 allow_inf_nan : bool ,
56- cache_strings : CacheStringsArg ,
57- allow_partial : bool ,
50+ cache_strings : StringCacheMode ,
51+ allow_partial : PartialMode ,
5852) -> PyResult < Bound < ' py , PyAny > > {
5953 let v_match = data
6054 . validate_bytes ( false , ValBytesMode { ser : BytesMode :: Utf8 } )
6155 . map_err ( |_| PyTypeError :: new_err ( "Expected bytes, bytearray or str" ) ) ?;
6256 let json_either_bytes = v_match. into_inner ( ) ;
6357 let json_bytes = json_either_bytes. as_slice ( ) ;
64- let cache_mode = match cache_strings {
65- CacheStringsArg :: Bool ( b) => b. into ( ) ,
66- CacheStringsArg :: Literal ( mode) => mode,
67- } ;
68- let partial_mode = if allow_partial {
69- PartialMode :: On
70- } else {
71- PartialMode :: Off
72- } ;
7358 let parse_builder = PythonParse {
7459 allow_inf_nan,
75- cache_mode,
76- partial_mode,
60+ cache_mode : cache_strings ,
61+ partial_mode : allow_partial ,
7762 catch_duplicate_keys : false ,
7863 lossless_floats : false ,
7964 } ;
0 commit comments