summaryrefslogtreecommitdiffstats
path: root/src/file/format/json.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/file/format/json.rs')
-rw-r--r--src/file/format/json.rs25
1 files changed, 2 insertions, 23 deletions
diff --git a/src/file/format/json.rs b/src/file/format/json.rs
index 290e17d..ed6c787 100644
--- a/src/file/format/json.rs
+++ b/src/file/format/json.rs
@@ -4,31 +4,10 @@ use std::collections::HashMap;
use std::error::Error;
use value::{Value, ValueKind};
-pub fn parse(uri: Option<&String>,
- text: &str,
- namespace: Option<&String>)
- -> Result<HashMap<String, Value>, Box<Error>> {
+pub fn parse(uri: Option<&String>, text: &str) -> Result<HashMap<String, Value>, Box<Error>> {
// Parse a JSON object value from the text
- let mut root: serde_json::Value = serde_json::from_str(text)?;
-
- // Limit to namespace
- if let Some(namespace) = namespace {
- root = serde_json::Value::Object(match root {
- serde_json::Value::Object(ref mut table) => {
- if let Some(serde_json::Value::Object(table)) =
- table.remove(namespace) {
- table
- } else {
- serde_json::Map::new()
- }
- }
-
- _ => serde_json::Map::new(),
- });
- };
-
// TODO: Have a proper error fire if the root of a file is ever not a Table
- let value = from_json_value(uri, &root);
+ let value = from_json_value(uri, &serde_json::from_str(text)?);
match value.kind {
ValueKind::Table(map) => Ok(map),