Skip to content

Commit

Permalink
Flag the whole json module behind the json feature
Browse files Browse the repository at this point in the history
  • Loading branch information
hansl committed Apr 11, 2024
1 parent 9cccd30 commit 4903ef4
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions core/interop/src/modules/json.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(feature = "json")]
//! Functions to create [`Module`]s that expose JSON data directly
//! as the default export.
#![allow(clippy::module_name_repetitions)]
Expand All @@ -9,7 +10,6 @@ use boa_engine::{js_string, Context, JsValue, Module};
///
/// # Errors
/// This will return an error if the JSON string is invalid or cannot be converted.
#[cfg(feature = "json")]
pub fn json_string_module(json: &str, context: &mut Context) -> boa_engine::JsResult<Module> {
let json_value = serde_json::from_str::<serde_json::Value>(json).map_err(|e| {
boa_engine::JsError::from_opaque(js_string!(format!("Failed to parse JSON: {}", e)).into())
Expand All @@ -18,7 +18,6 @@ pub fn json_string_module(json: &str, context: &mut Context) -> boa_engine::JsRe
Ok(Module::from_value_as_default(value, context))
}

#[cfg(feature = "json")]
#[test]
fn test_json_module_from_str() {
use crate::loaders::HashMapModuleLoader;
Expand Down

0 comments on commit 4903ef4

Please sign in to comment.