Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialize serde_json::Value::Object contains Null/None get error Custom("unsupported value") #110

Open
pymongo opened this issue Nov 18, 2023 · 0 comments

Comments

@pymongo
Copy link

pymongo commented Nov 18, 2023

I try below code but got error Err value: Custom("unsupported value")

serde_urlencoded::to_string(&serde_json::json!({
    "limit": serde_json::Value::Null,
    "timestamp": 1700283922524u64 
})).unwrap();

serde_json::Value

impl Serialize for Value {
    #[inline]
    fn serialize<S>(&self, serializer: S) -> result::Result<S::Ok, S::Error>
    where
        S: ::serde::Serializer,
    {
        match self {
            Value::Null => serializer.serialize_unit(),

should serialize Null/None return Ok?

fn serialize_unit(self) -> Result<S::Ok, Error> {
Err(self.sink.unsupported())
}

pymongo added a commit to pymongo/serde_urlencoded that referenced this issue Nov 18, 2023
@pymongo pymongo changed the title Serialize Map/Object contains Null or None get error Custom("unsupported value") Serialize serde_json::Value::Object contains Null/None get error Custom("unsupported value") Nov 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant