Skip to content

Error convert string Json to Document using Serde. #189

@almir-lima

Description

@almir-lima

Hi everyone, i try convert a String JSON to Document, but i receive a error when key value is a Integer, if i put in quotes number then it's work.

it's work:
let d: Document = serde_json::from_str( &"{ "id" : "1" }".to_string() ).unwrap();

Don't work:
let d: Document = serde_json::from_str( &"{ "id" : 1 }".to_string() ).unwrap();

I receive this message below:

thread '' panicked at 'called Result::unwrap() on an Err value: Error("invalid type: integer 1, expected a signed integer", line: 1, column: 10)'
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

Metadata

Metadata

Assignees

No one assigned

    Labels

    tracked-in-jiraTicket filed in Mongo's Jira system

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions