diff --git a/src/libextra/json.rs b/src/libextra/json.rs index 06b6d0cb29e8..3567d5001bdf 100644 --- a/src/libextra/json.rs +++ b/src/libextra/json.rs @@ -27,6 +27,7 @@ use std::to_str; use serialize::Encodable; use serialize; use sort::Sort; +use treemap::TreeMap; /// Represents a json value pub enum Json { @@ -1340,6 +1341,16 @@ impl ToJson for HashMap<~str, A> { } } +impl ToJson for TreeMap<~str, A> { + fn to_json(&self) -> Json { + let mut d = HashMap::new(); + for self.iter().advance |(key, value)| { + d.insert(copy *key, value.to_json()); + } + Object(~d) + } +} + impl ToJson for Option { fn to_json(&self) -> Json { match *self {