@@ -99,6 +99,7 @@ def stac_object_from_dict(
99
99
d : Dict [str , Any ],
100
100
href : Optional [str ] = None ,
101
101
root : Optional ["Catalog_Type" ] = None ,
102
+ preserve_dict : bool = True ,
102
103
) -> "STACObject_Type" :
103
104
if identify_stac_object_type (d ) == pystac .STACObjectType .ITEM :
104
105
collection_cache = None
@@ -114,15 +115,21 @@ def stac_object_from_dict(
114
115
d = migrate_to_latest (d , info )
115
116
116
117
if info .object_type == pystac .STACObjectType .CATALOG :
117
- result = pystac .Catalog .from_dict (d , href = href , root = root , migrate = False )
118
+ result = pystac .Catalog .from_dict (
119
+ d , href = href , root = root , migrate = False , preserve_dict = preserve_dict
120
+ )
118
121
result ._stac_io = self
119
122
return result
120
123
121
124
if info .object_type == pystac .STACObjectType .COLLECTION :
122
- return pystac .Collection .from_dict (d , href = href , root = root , migrate = False )
125
+ return pystac .Collection .from_dict (
126
+ d , href = href , root = root , migrate = False , preserve_dict = preserve_dict
127
+ )
123
128
124
129
if info .object_type == pystac .STACObjectType .ITEM :
125
- return pystac .Item .from_dict (d , href = href , root = root , migrate = False )
130
+ return pystac .Item .from_dict (
131
+ d , href = href , root = root , migrate = False , preserve_dict = preserve_dict
132
+ )
126
133
127
134
raise ValueError (f"Unknown STAC object type { info .object_type } " )
128
135
@@ -164,7 +171,7 @@ def read_stac_object(
164
171
"""
165
172
d = self .read_json (source )
166
173
href = source if isinstance (source , str ) else source .get_absolute_href ()
167
- return self .stac_object_from_dict (d , href = href , root = root )
174
+ return self .stac_object_from_dict (d , href = href , root = root , preserve_dict = False )
168
175
169
176
def save_json (
170
177
self , dest : Union [str , "Link_Type" ], json_dict : Dict [str , Any ]
0 commit comments