From 0d7b0d3c18166bb65643afda9651e962b6f03d55 Mon Sep 17 00:00:00 2001 From: Neil Mitchell Date: Thu, 18 May 2023 10:34:39 +0100 Subject: [PATCH 1/2] Add an example of producing a Null in a json! literal I tried to do this, and while you can piece together the way to do this from the interpolation comment, it's the one piece of direct JSON syntax that isn't immediately obvious. --- src/macros.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/macros.rs b/src/macros.rs index 5287998b4..70acde25e 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -2,6 +2,7 @@ /// /// ``` /// # use serde_json::json; +/// # use serde_json::Value; /// # /// let value = json!({ /// "code": 200, @@ -10,7 +11,8 @@ /// "features": [ /// "serde", /// "json" -/// ] +/// ], +/// "empty": Value::Null /// } /// }); /// ``` From 009a53b472017dbec18442611fb849b9801db41d Mon Sep 17 00:00:00 2001 From: Neil Mitchell Date: Thu, 1 Jun 2023 15:29:37 +0100 Subject: [PATCH 2/2] Switch to using null --- src/macros.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index 70acde25e..0936f7231 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -2,7 +2,6 @@ /// /// ``` /// # use serde_json::json; -/// # use serde_json::Value; /// # /// let value = json!({ /// "code": 200, @@ -12,7 +11,7 @@ /// "serde", /// "json" /// ], -/// "empty": Value::Null +/// "empty": null /// } /// }); /// ```