Preserve order when serializing/deserialize json by default. (#3126)

This commit is contained in:
Andrés N. Robalino
2021-03-04 00:35:13 -06:00
committed by GitHub
parent 9c375b33a6
commit 0b71e45072
118 changed files with 2487 additions and 1322 deletions

View File

@ -1,13 +1,3 @@
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use serde::ser;
use crate::value::{self, Map, Value};
@ -36,7 +26,8 @@ impl ArrayBuilder {
/// Insert a value into the array.
pub fn push<T: ser::Serialize>(mut self, v: T) -> ArrayBuilder {
self.array.push(value::to_value(&v));
self.array
.push(value::to_value(&v).expect("failed to serialize"));
self
}
@ -91,7 +82,10 @@ impl ObjectBuilder {
S: Into<String>,
V: ser::Serialize,
{
self.object.insert(key.into(), value::to_value(&value));
self.object.insert(
key.into(),
value::to_value(&value).expect("failed to serialize"),
);
self
}