File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -476,6 +476,7 @@ pub struct SiteID(pub u32);
476
476
#[ derive( Serialize , Deserialize , Clone , Debug ) ]
477
477
pub struct Parented < P : RefTrait , T > {
478
478
pub parent : P ,
479
+ #[ serde( flatten) ]
479
480
pub bundle : T ,
480
481
}
481
482
Original file line number Diff line number Diff line change @@ -870,6 +870,6 @@ mod tests {
870
870
..Default :: default ( )
871
871
} ;
872
872
let s = yaserde:: ser:: to_string_with_config ( & sdf, & config) . unwrap ( ) ;
873
- std:: fs:: write ( "test.sdf" , s) ;
873
+ std:: fs:: write ( "test.sdf" , s) . unwrap ( ) ;
874
874
}
875
875
}
Original file line number Diff line number Diff line change @@ -202,6 +202,18 @@ impl Site {
202
202
serde_json:: to_vec_pretty ( self )
203
203
}
204
204
205
+ pub fn to_bytes_json_pretty ( & self ) -> serde_json:: Result < Vec < u8 > > {
206
+ serde_json:: to_vec ( self )
207
+ }
208
+
209
+ pub fn to_string_json ( & self ) -> serde_json:: Result < String > {
210
+ serde_json:: to_string ( self )
211
+ }
212
+
213
+ pub fn to_string_json_pretty ( & self ) -> serde_json:: Result < String > {
214
+ serde_json:: to_string_pretty ( self )
215
+ }
216
+
205
217
pub fn from_bytes_ron < ' a > ( s : & ' a [ u8 ] ) -> ron:: error:: SpannedResult < Self > {
206
218
ron:: de:: from_bytes ( s)
207
219
}
@@ -258,4 +270,12 @@ mod tests {
258
270
let site_string = map. to_site ( ) . unwrap ( ) . to_bytes_json ( ) . unwrap ( ) ;
259
271
Site :: from_bytes_json ( & site_string) . unwrap ( ) ;
260
272
}
273
+
274
+ #[ test]
275
+ fn produce_json_string ( ) {
276
+ let data = std:: fs:: read ( "../assets/demo_maps/office.building.yaml" ) . unwrap ( ) ;
277
+ let map = BuildingMap :: from_bytes ( & data) . unwrap ( ) ;
278
+ let text = map. to_site ( ) . unwrap ( ) . to_string_json_pretty ( ) . unwrap ( ) ;
279
+ println ! ( "{text}" ) ;
280
+ }
261
281
}
You can’t perform that action at this time.
0 commit comments