aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Vander Stoep <jeffv@google.com>2023-02-22 00:19:08 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-02-22 00:19:08 +0000
commit089f5d6ff6adecc45e0c0dbea34b359948ab6831 (patch)
tree7a9067c4ee61587d715f9c2c3e397c6ff6e38028
parenteb12c567c98b694b1c470962e6b1e728bd1a77d8 (diff)
parentf23d18fe098fbc0fd7b8068545c33447f561a4a6 (diff)
downloadserde_json-089f5d6ff6adecc45e0c0dbea34b359948ab6831.tar.gz
Upgrade serde_json to 1.0.93 am: cd91805edb am: 2459960e2c am: e3e4255555 am: f23d18fe09
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/serde_json/+/2442022 Change-Id: Idd42cfce6e48ed6ec45c108c714faa2138763f18 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--.github/workflows/ci.yml2
-rw-r--r--Android.bp2
-rw-r--r--Cargo.toml6
-rw-r--r--Cargo.toml.orig6
-rw-r--r--LICENSE-APACHE25
-rw-r--r--METADATA10
-rw-r--r--README.md22
-rw-r--r--src/lib.rs20
-rw-r--r--src/raw.rs2
-rw-r--r--src/value/mod.rs8
-rw-r--r--src/value/ser.rs34
-rw-r--r--tests/test.rs21
13 files changed, 91 insertions, 69 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 37acde7..3fa35ed 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,6 +1,6 @@
{
"git": {
- "sha1": "26f147fde7ce6441f7db978131150605c5500c28"
+ "sha1": "0ebeede28a0d5f0f07f18124078f55d62b180a2d"
},
"path_in_vcs": ""
} \ No newline at end of file
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 411aa42..bfaffaf 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -110,7 +110,7 @@ jobs:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
- uses: dtolnay/install@cargo-fuzz
- - run: cargo fuzz build -O
+ - run: cargo fuzz check
outdated:
name: Outdated
diff --git a/Android.bp b/Android.bp
index d2fcba7..14a8c81 100644
--- a/Android.bp
+++ b/Android.bp
@@ -43,7 +43,7 @@ rust_library {
host_supported: true,
crate_name: "serde_json",
cargo_env_compat: true,
- cargo_pkg_version: "1.0.91",
+ cargo_pkg_version: "1.0.93",
srcs: ["src/lib.rs"],
edition: "2018",
features: [
diff --git a/Cargo.toml b/Cargo.toml
index 08c94aa..cff28cd 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,13 +13,13 @@
edition = "2018"
rust-version = "1.36"
name = "serde_json"
-version = "1.0.91"
+version = "1.0.93"
authors = [
"Erick Tryzelaar <erick.tryzelaar@gmail.com>",
"David Tolnay <dtolnay@gmail.com>",
]
description = "A JSON serialization file format"
-documentation = "https://docs.serde.rs/serde_json/"
+documentation = "https://docs.rs/serde_json"
readme = "README.md"
keywords = [
"json",
@@ -70,7 +70,7 @@ default-features = false
version = "1.0"
[dev-dependencies.indoc]
-version = "1.0"
+version = "2.0"
[dev-dependencies.ref-cast]
version = "1.0"
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 2feb6dd..3e8fa0d 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,10 +1,10 @@
[package]
name = "serde_json"
-version = "1.0.91" # remember to update html_root_url
+version = "1.0.93" # remember to update html_root_url
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
categories = ["encoding", "parser-implementations", "no-std"]
description = "A JSON serialization file format"
-documentation = "https://docs.serde.rs/serde_json/"
+documentation = "https://docs.rs/serde_json"
edition = "2018"
keywords = ["json", "serde", "serialization"]
license = "MIT OR Apache-2.0"
@@ -19,7 +19,7 @@ ryu = "1.0"
[dev-dependencies]
automod = "1.0"
-indoc = "1.0"
+indoc = "2.0"
ref-cast = "1.0"
rustversion = "1.0"
serde = { version = "1.0.100", features = ["derive"] }
diff --git a/LICENSE-APACHE b/LICENSE-APACHE
index 16fe87b..1b5ec8b 100644
--- a/LICENSE-APACHE
+++ b/LICENSE-APACHE
@@ -174,28 +174,3 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
-Copyright [yyyy] [name of copyright owner]
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/METADATA b/METADATA
index 6d8cf40..6040edb 100644
--- a/METADATA
+++ b/METADATA
@@ -11,13 +11,13 @@ third_party {
}
url {
type: ARCHIVE
- value: "https://static.crates.io/crates/serde_json/serde_json-1.0.91.crate"
+ value: "https://static.crates.io/crates/serde_json/serde_json-1.0.93.crate"
}
- version: "1.0.91"
+ version: "1.0.93"
license_type: NOTICE
last_upgrade_date {
- year: 2022
- month: 12
- day: 19
+ year: 2023
+ month: 2
+ day: 17
}
}
diff --git a/README.md b/README.md
index 50b5d45..d704979 100644
--- a/README.md
+++ b/README.md
@@ -18,8 +18,8 @@ serde_json = "1.0"
You may be looking for:
-- [JSON API documentation](https://docs.serde.rs/serde_json/)
-- [Serde API documentation](https://docs.serde.rs/serde/)
+- [JSON API documentation](https://docs.rs/serde_json)
+- [Serde API documentation](https://docs.rs/serde)
- [Detailed documentation about Serde](https://serde.rs/)
- [Setting up `#[derive(Serialize, Deserialize)]`](https://serde.rs/derive.html)
- [Release notes](https://github.com/serde-rs/json/releases)
@@ -126,7 +126,7 @@ without quotation marks involves converting from a JSON string to a Rust string
with [`as_str()`] or avoiding the use of `Value` as described in the following
section.
-[`as_str()`]: https://docs.serde.rs/serde_json/enum.Value.html#method.as_str
+[`as_str()`]: https://docs.rs/serde_json/1/serde_json/enum.Value.html#method.as_str
The `Value` representation is sufficient for very basic tasks but can be tedious
to work with for anything more significant. Error handling is verbose to
@@ -363,14 +363,14 @@ For JSON support in Serde without a memory allocator, please see the
[`serde-json-core`]: https://github.com/rust-embedded-community/serde-json-core
-[value]: https://docs.serde.rs/serde_json/value/enum.Value.html
-[from_str]: https://docs.serde.rs/serde_json/de/fn.from_str.html
-[from_slice]: https://docs.serde.rs/serde_json/de/fn.from_slice.html
-[from_reader]: https://docs.serde.rs/serde_json/de/fn.from_reader.html
-[to_string]: https://docs.serde.rs/serde_json/ser/fn.to_string.html
-[to_vec]: https://docs.serde.rs/serde_json/ser/fn.to_vec.html
-[to_writer]: https://docs.serde.rs/serde_json/ser/fn.to_writer.html
-[macro]: https://docs.serde.rs/serde_json/macro.json.html
+[value]: https://docs.rs/serde_json/1/serde_json/value/enum.Value.html
+[from_str]: https://docs.rs/serde_json/1/serde_json/de/fn.from_str.html
+[from_slice]: https://docs.rs/serde_json/1/serde_json/de/fn.from_slice.html
+[from_reader]: https://docs.rs/serde_json/1/serde_json/de/fn.from_reader.html
+[to_string]: https://docs.rs/serde_json/1/serde_json/ser/fn.to_string.html
+[to_vec]: https://docs.rs/serde_json/1/serde_json/ser/fn.to_vec.html
+[to_writer]: https://docs.rs/serde_json/1/serde_json/ser/fn.to_writer.html
+[macro]: https://docs.rs/serde_json/1/serde_json/macro.json.html
<br>
diff --git a/src/lib.rs b/src/lib.rs
index fdd95a1..48d0fe2 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -104,7 +104,7 @@
//! a JSON string to a Rust string with [`as_str()`] or avoiding the use of
//! `Value` as described in the following section.
//!
-//! [`as_str()`]: https://docs.serde.rs/serde_json/enum.Value.html#method.as_str
+//! [`as_str()`]: crate::Value::as_str
//!
//! The `Value` representation is sufficient for very basic tasks but can be
//! tedious to work with for anything more significant. Error handling is
@@ -290,17 +290,17 @@
//! For JSON support in Serde without a memory allocator, please see the
//! [`serde-json-core`] crate.
//!
-//! [value]: https://docs.serde.rs/serde_json/value/enum.Value.html
-//! [from_str]: https://docs.serde.rs/serde_json/de/fn.from_str.html
-//! [from_slice]: https://docs.serde.rs/serde_json/de/fn.from_slice.html
-//! [from_reader]: https://docs.serde.rs/serde_json/de/fn.from_reader.html
-//! [to_string]: https://docs.serde.rs/serde_json/ser/fn.to_string.html
-//! [to_vec]: https://docs.serde.rs/serde_json/ser/fn.to_vec.html
-//! [to_writer]: https://docs.serde.rs/serde_json/ser/fn.to_writer.html
-//! [macro]: https://docs.serde.rs/serde_json/macro.json.html
+//! [value]: crate::value::Value
+//! [from_str]: crate::de::from_str
+//! [from_slice]: crate::de::from_slice
+//! [from_reader]: crate::de::from_reader
+//! [to_string]: crate::ser::to_string
+//! [to_vec]: crate::ser::to_vec
+//! [to_writer]: crate::ser::to_writer
+//! [macro]: crate::json
//! [`serde-json-core`]: https://github.com/rust-embedded-community/serde-json-core
-#![doc(html_root_url = "https://docs.rs/serde_json/1.0.91")]
+#![doc(html_root_url = "https://docs.rs/serde_json/1.0.93")]
// Ignored clippy lints
#![allow(
clippy::collapsible_else_if,
diff --git a/src/raw.rs b/src/raw.rs
index c8377ac..6aa4ffc 100644
--- a/src/raw.rs
+++ b/src/raw.rs
@@ -112,7 +112,7 @@ use serde::ser::{Serialize, SerializeStruct, Serializer};
/// raw_value: Box<RawValue>,
/// }
/// ```
-#[repr(C)]
+#[cfg_attr(not(doc), repr(transparent))]
#[cfg_attr(docsrs, doc(cfg(feature = "raw_value")))]
pub struct RawValue {
json: str,
diff --git a/src/value/mod.rs b/src/value/mod.rs
index c467df6..470b6b2 100644
--- a/src/value/mod.rs
+++ b/src/value/mod.rs
@@ -85,10 +85,10 @@
//! # untyped_example().unwrap();
//! ```
//!
-//! [macro]: https://docs.serde.rs/serde_json/macro.json.html
-//! [from_str]: https://docs.serde.rs/serde_json/de/fn.from_str.html
-//! [from_slice]: https://docs.serde.rs/serde_json/de/fn.from_slice.html
-//! [from_reader]: https://docs.serde.rs/serde_json/de/fn.from_reader.html
+//! [macro]: crate::json
+//! [from_str]: crate::de::from_str
+//! [from_slice]: crate::de::from_slice
+//! [from_reader]: crate::de::from_reader
use crate::error::Error;
use crate::io;
diff --git a/src/value/ser.rs b/src/value/ser.rs
index 892a63d..a29814e 100644
--- a/src/value/ser.rs
+++ b/src/value/ser.rs
@@ -5,6 +5,8 @@ use crate::value::{to_value, Value};
use alloc::borrow::ToOwned;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
+#[cfg(not(feature = "arbitrary_precision"))]
+use core::convert::TryFrom;
use core::fmt::Display;
use core::result;
use serde::ser::{Impossible, Serialize};
@@ -92,9 +94,22 @@ impl serde::Serializer for Serializer {
Ok(Value::Number(value.into()))
}
- #[cfg(feature = "arbitrary_precision")]
fn serialize_i128(self, value: i128) -> Result<Value> {
- Ok(Value::Number(value.into()))
+ #[cfg(feature = "arbitrary_precision")]
+ {
+ Ok(Value::Number(value.into()))
+ }
+
+ #[cfg(not(feature = "arbitrary_precision"))]
+ {
+ if let Ok(value) = u64::try_from(value) {
+ Ok(Value::Number(value.into()))
+ } else if let Ok(value) = i64::try_from(value) {
+ Ok(Value::Number(value.into()))
+ } else {
+ Err(Error::syntax(ErrorCode::NumberOutOfRange, 0, 0))
+ }
+ }
}
#[inline]
@@ -117,9 +132,20 @@ impl serde::Serializer for Serializer {
Ok(Value::Number(value.into()))
}
- #[cfg(feature = "arbitrary_precision")]
fn serialize_u128(self, value: u128) -> Result<Value> {
- Ok(Value::Number(value.into()))
+ #[cfg(feature = "arbitrary_precision")]
+ {
+ Ok(Value::Number(value.into()))
+ }
+
+ #[cfg(not(feature = "arbitrary_precision"))]
+ {
+ if let Ok(value) = u64::try_from(value) {
+ Ok(Value::Number(value.into()))
+ } else {
+ Err(Error::syntax(ErrorCode::NumberOutOfRange, 0, 0))
+ }
+ }
}
#[inline]
diff --git a/tests/test.rs b/tests/test.rs
index c205072..f62a545 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -2180,6 +2180,27 @@ fn test_integer128() {
]);
}
+#[test]
+fn test_integer128_to_value() {
+ let signed = &[i128::from(i64::min_value()), i128::from(u64::max_value())];
+ let unsigned = &[0, u128::from(u64::max_value())];
+
+ for integer128 in signed {
+ let expected = integer128.to_string();
+ assert_eq!(to_value(integer128).unwrap().to_string(), expected);
+ }
+
+ for integer128 in unsigned {
+ let expected = integer128.to_string();
+ assert_eq!(to_value(integer128).unwrap().to_string(), expected);
+ }
+
+ if !cfg!(feature = "arbitrary_precision") {
+ let err = to_value(u128::from(u64::max_value()) + 1).unwrap_err();
+ assert_eq!(err.to_string(), "number out of range");
+ }
+}
+
#[cfg(feature = "raw_value")]
#[test]
fn test_borrowed_raw_value() {