diff --git a/src/to-json/src/ffi.rs b/src/to-json/src/ffi.rs index dcaf66d..f728598 100644 --- a/src/to-json/src/ffi.rs +++ b/src/to-json/src/ffi.rs @@ -1,4 +1,4 @@ -use crate::convert::to_json; +use crate::json::to_json; use std::ffi::{c_char, CStr, CString}; fn to_c_string(string: String) -> *const c_char { // fetch c-style ptr of string diff --git a/src/to-json/src/convert.rs b/src/to-json/src/json.rs similarity index 63% rename from src/to-json/src/convert.rs rename to src/to-json/src/json.rs index 9393fad..8f79d44 100644 --- a/src/to-json/src/convert.rs +++ b/src/to-json/src/json.rs @@ -1,10 +1,11 @@ +use serde_json as json; use crate::parser::{parser, Value}; fn json_convert(content: &str) -> Result { // convert to JSON format let data = match parser(content)? { - Value::JSON(json) => serde_json::to_string(&json), - Value::YAML(yaml) => serde_json::to_string(&yaml), - Value::TOML(toml) => serde_json::to_string(&toml), + Value::JSON(_json) => json::to_string(&_json), + Value::YAML(_yaml) => json::to_string(&_yaml), + Value::TOML(_toml) => json::to_string(&_toml), }; match data { Ok(data) => Ok(data), @@ -15,6 +16,6 @@ fn json_convert(content: &str) -> Result { // convert to JSON fo pub fn to_json(content: &str) -> Option { // to JSON string match json_convert(content) { Ok(data) => Some(data), - Err(_) => None, + Err(_) => None, // convert failed } } diff --git a/src/to-json/src/lib.rs b/src/to-json/src/lib.rs index f04b9c3..d5af57d 100644 --- a/src/to-json/src/lib.rs +++ b/src/to-json/src/lib.rs @@ -1,4 +1,4 @@ mod ffi; +mod json; mod tests; mod parser; -mod convert; diff --git a/src/to-json/src/tests.rs b/src/to-json/src/tests.rs index ee74871..3c832c9 100644 --- a/src/to-json/src/tests.rs +++ b/src/to-json/src/tests.rs @@ -1,4 +1,4 @@ -use crate::convert::to_json; +use crate::json::to_json; #[allow(dead_code)] const JSON_TEST_CONTENT: &str = r#"