We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9e67bc3 commit bf1f69cCopy full SHA for bf1f69c
src/libextra/json.rs
@@ -27,6 +27,7 @@ use std::to_str;
27
use serialize::Encodable;
28
use serialize;
29
use sort::Sort;
30
+use treemap::TreeMap;
31
32
/// Represents a json value
33
pub enum Json {
@@ -1340,6 +1341,16 @@ impl<A:ToJson + Copy> ToJson for HashMap<~str, A> {
1340
1341
}
1342
1343
1344
+impl<A:ToJson + Copy> ToJson for TreeMap<~str, A> {
1345
+ fn to_json(&self) -> Json {
1346
+ let mut d = HashMap::new();
1347
+ for self.iter().advance |(key, value)| {
1348
+ d.insert(copy *key, value.to_json());
1349
+ }
1350
+ Object(~d)
1351
1352
+}
1353
+
1354
impl<A:ToJson> ToJson for Option<A> {
1355
fn to_json(&self) -> Json {
1356
match *self {
0 commit comments