@@ -218,34 +218,24 @@ impl<'de> Deserialize<'de> for Typographies {
218218 match & value {
219219 // Traditional array format: [{ fontFamily: "Arial", ... }, null, { ... }]
220220 Value :: Array ( arr) => {
221- // Check if this looks like a traditional typography array (array of objects/nulls)
222- // vs a compact format that accidentally starts with an array
223- let is_traditional = arr. iter ( ) . all ( |v| v. is_object ( ) || v. is_null ( ) ) ;
224- if is_traditional {
225- let mut result = Vec :: with_capacity ( arr. len ( ) ) ;
226- for item in arr {
227- match item {
228- Value :: Null => result. push ( None ) ,
229- Value :: Object ( _) => {
230- let typo: Typography = serde_json:: from_value ( item. clone ( ) )
231- . map_err ( D :: Error :: custom) ?;
232- result. push ( Some ( typo) ) ;
233- }
234- _ => {
235- return Err ( D :: Error :: custom ( format ! (
236- "Typography array must contain objects or null, got: {:?}" ,
237- item
238- ) ) ) ;
239- }
221+ let mut result = Vec :: with_capacity ( arr. len ( ) ) ;
222+ for item in arr {
223+ match item {
224+ Value :: Null => result. push ( None ) ,
225+ Value :: Object ( _) => {
226+ let typo: Typography =
227+ serde_json:: from_value ( item. clone ( ) ) . map_err ( D :: Error :: custom) ?;
228+ result. push ( Some ( typo) ) ;
229+ }
230+ // Non-object/null values mean this is not a valid traditional array format
231+ _ => {
232+ return Err ( D :: Error :: custom (
233+ "Typography value cannot start with an array. Use object format with property-level arrays instead." ,
234+ ) ) ;
240235 }
241236 }
242- Ok ( Self ( result) )
243- } else {
244- // Top-level array that's not a traditional format is an error
245- Err ( D :: Error :: custom (
246- "Typography value cannot start with an array. Use object format with property-level arrays instead." ,
247- ) )
248237 }
238+ Ok ( Self ( result) )
249239 }
250240 // Compact object format: { fontFamily: "Arial", fontSize: ["16px", null, "20px"], ... }
251241 Value :: Object ( obj) => {
0 commit comments