deprecate using SerdeValue, SerdeMap and serde_to_value
as they are just wrapper around serde_json::{Value, Map, to_value}.
Instead expose the serde_json and serde crates used.
This commit is contained in:
19
src/lib.rs
19
src/lib.rs
@@ -398,8 +398,25 @@ pub use crate::stream::TlsConnector;
|
|||||||
// re-export
|
// re-export
|
||||||
#[cfg(feature = "cookies")]
|
#[cfg(feature = "cookies")]
|
||||||
pub use cookie::Cookie;
|
pub use cookie::Cookie;
|
||||||
|
|
||||||
#[cfg(feature = "json")]
|
#[cfg(feature = "json")]
|
||||||
pub use serde_json::{to_value as serde_to_value, Map as SerdeMap, Value as SerdeValue};
|
pub use {serde, serde_json};
|
||||||
|
|
||||||
|
#[cfg(feature = "json")]
|
||||||
|
#[deprecated(note = "use ureq::serde_json::Map instead")]
|
||||||
|
pub type SerdeMap<K, V> = serde_json::Map<K, V>;
|
||||||
|
|
||||||
|
#[cfg(feature = "json")]
|
||||||
|
#[deprecated(note = "use ureq::serde_json::Value instead")]
|
||||||
|
pub type SerdeValue = serde_json::Value;
|
||||||
|
|
||||||
|
#[cfg(feature = "json")]
|
||||||
|
#[deprecated(note = "use ureq::serde_json::to_value instead")]
|
||||||
|
pub fn serde_to_value<T: serde::Serialize>(
|
||||||
|
value: T,
|
||||||
|
) -> std::result::Result<serde_json::Value, serde_json::Error> {
|
||||||
|
serde_json::to_value(value)
|
||||||
|
}
|
||||||
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ fn content_length_on_json() {
|
|||||||
test::set_handler("/content_length_on_json", |_unit| {
|
test::set_handler("/content_length_on_json", |_unit| {
|
||||||
test::make_response(200, "OK", vec![], vec![])
|
test::make_response(200, "OK", vec![], vec![])
|
||||||
});
|
});
|
||||||
let mut json = SerdeMap::new();
|
let mut json = serde_json::Map::new();
|
||||||
json.insert(
|
json.insert(
|
||||||
"Hello".to_string(),
|
"Hello".to_string(),
|
||||||
serde_json::Value::String("World!!!".to_string()),
|
serde_json::Value::String("World!!!".to_string()),
|
||||||
@@ -87,7 +87,7 @@ fn content_type_on_json() {
|
|||||||
test::set_handler("/content_type_on_json", |_unit| {
|
test::set_handler("/content_type_on_json", |_unit| {
|
||||||
test::make_response(200, "OK", vec![], vec![])
|
test::make_response(200, "OK", vec![], vec![])
|
||||||
});
|
});
|
||||||
let mut json = SerdeMap::new();
|
let mut json = serde_json::Map::new();
|
||||||
json.insert(
|
json.insert(
|
||||||
"Hello".to_string(),
|
"Hello".to_string(),
|
||||||
serde_json::Value::String("World!!!".to_string()),
|
serde_json::Value::String("World!!!".to_string()),
|
||||||
@@ -106,7 +106,7 @@ fn content_type_not_overriden_on_json() {
|
|||||||
test::set_handler("/content_type_not_overriden_on_json", |_unit| {
|
test::set_handler("/content_type_not_overriden_on_json", |_unit| {
|
||||||
test::make_response(200, "OK", vec![], vec![])
|
test::make_response(200, "OK", vec![], vec![])
|
||||||
});
|
});
|
||||||
let mut json = SerdeMap::new();
|
let mut json = serde_json::Map::new();
|
||||||
json.insert(
|
json.insert(
|
||||||
"Hello".to_string(),
|
"Hello".to_string(),
|
||||||
serde_json::Value::String("World!!!".to_string()),
|
serde_json::Value::String("World!!!".to_string()),
|
||||||
|
|||||||
Reference in New Issue
Block a user