Skip to content

Commit ae3f85d

Browse files
committed
fix: enable conver to serde value
1 parent 0486431 commit ae3f85d

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/package_json/simd.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -120,25 +120,25 @@ impl PackageJson {
120120

121121
#[cfg(feature = "package_json_raw_json_api")]
122122
fn init_serde_json(&mut self, value: &JSONMap) {
123-
// const KEYS_TO_KEEP: [&str; 9] = [
124-
// "name",
125-
// "version",
126-
// "sideEffects",
127-
// "type",
128-
// "main",
129-
// "module",
130-
// "exports",
131-
// "imports",
132-
// "browser",
133-
// ];
134-
// let mut json_map = serde_json::value::Map::with_capacity(KEYS_TO_KEEP.len());
135-
//
136-
// for key in KEYS_TO_KEEP {
137-
// if let Some(name) = value.get(key).and_then(|v| from_refborrowed_value(v).ok()) {
138-
// json_map.insert(key.to_string(), name);
139-
// }
140-
// }
141-
// self.serde_json = std::sync::Arc::new(serde_json::Value::Object(json_map));
123+
const KEYS_TO_KEEP: [&str; 9] = [
124+
"name",
125+
"version",
126+
"sideEffects",
127+
"type",
128+
"main",
129+
"module",
130+
"exports",
131+
"imports",
132+
"browser",
133+
];
134+
let mut json_map = serde_json::value::Map::with_capacity(KEYS_TO_KEEP.len());
135+
136+
for key in KEYS_TO_KEEP {
137+
if let Some(name) = value.get(key).and_then(|v| from_refborrowed_value(v).ok()) {
138+
json_map.insert(key.to_string(), name);
139+
}
140+
}
141+
self.serde_json = std::sync::Arc::new(serde_json::Value::Object(json_map));
142142
}
143143

144144
fn get_value_by_paths<'a>(fields: &'a JSONMap, paths: &[String]) -> Option<&'a JSONValue<'a>> {

0 commit comments

Comments
 (0)