Skip to main content
Filter by
Sorted by
Tagged with
3 votes
1 answer
65 views

I'm trying to work through Rust and using serde_yml as opposed to serde_yaml which has caused me much great confusion, and can't seem to find examples for parsing yaml from a file. I've been running ...
Ender's user avatar
  • 1,914
1 vote
0 answers
99 views

I am trying to write custom deserialisers for a multi-level data structure (for serde in Rust), and I need some help connecting the levels together. For example, I have something like: struct A { x:...
Martin Ellison's user avatar
2 votes
1 answer
96 views

I've implemented a Rust clone of bgpdump that displays MRT messages in the same format as bgpdump. To print the message, I implemented the Display trait and printed it to stdout. However, I'm ...
vgauthier's user avatar
1 vote
0 answers
48 views

Is it possible to use Serde to deserialize following JSON into single simple struct instead of having nested structs? JSON: { name: "Name", server: { name: "Server&...
JJ.'s user avatar
  • 1,137
2 votes
0 answers
114 views

I'm working with Rust and tokio to process incoming data from a channel (e.g., TCP). The data arrives as a String representing a JSON payload. My goal is to deserialize this JSON into a Rust struct ...
IamMan's user avatar
  • 462
0 votes
0 answers
51 views

I'm working on a Tauri application that uses tauri-specta for type safety and I can't figure out how to properly serialize dates. This is the file where most of the serialization and deserialization ...
Andrew's user avatar
  • 642
3 votes
1 answer
148 views

I want to create a trait that requires all of its implementations to derive serialize and deserialize form serde. Additionally, the trait must also force the implementation of Debug and Clone. This is ...
Evry's user avatar
  • 127
0 votes
0 answers
32 views

I am trying to implement a function that requests a service by URL and deserializes the response into a structure. For a certain structure it works correct: use serde::Deserialize; #[derive(...
Fomalhaut's user avatar
  • 9,991
0 votes
1 answer
118 views

How can I force serde to parse a JSON Number as a Rust u16 type? Below I parse a JSON file. json_data is of type Value. This only has a as_u64() method, no as_u16(). As a result I first have to parse ...
Baldrick's user avatar
  • 11.2k
0 votes
1 answer
62 views

I have a json body object, which has a key called "symbols", and its value is Vec (T is also object). T contains a field called "symbol". I want to find the object containing a ...
Ahmet Yazıcı's user avatar
1 vote
1 answer
85 views

When handling JSON in Actix Web using serde, the default deserialization errors (missing field ...) do not provide a list of all missing fields. Instead, serde stops at the first missing field and ...
Shvargon's user avatar
1 vote
2 answers
436 views

Currently working on a project where I need to serialize some types to a string from a dependency. I am trying to figure out the most efficient way to convert said types into a string while also ...
starsoccer's user avatar
0 votes
0 answers
22 views

I'm attempting to use a wrapper around chrono::DateTime<Utc> in a struct that I'm using as a model for a database row. I am using a wrapper so that I can implement other traits on it. However, I ...
jovie's user avatar
  • 1
0 votes
0 answers
65 views

I have an app that has 2 functions that take a type we’ll call T and U. They are stored in an enum that looks like this: #[derive(Serialize, Deserialize)] #[serde(untagged)] enum V { T { w: String ...
ThreeRoundedSquares's user avatar
0 votes
1 answer
158 views

Most examples showing deserialization of JSON with Rust and serde_json show deserialization into a known structure format, using a defined struct. Is it possible to deserialize a JSON document with an ...
user2138149's user avatar
  • 18.6k
1 vote
1 answer
147 views

How to make serde through an error if the json string contains an extra field. This is my code #[derive(Debug, serde::Deserialize)] struct C { a: A, b: B, } #[derive(Debug, serde::Deserialize)...
Harry's user avatar
  • 4,132
1 vote
1 answer
77 views

Imagine I need to parse the following body: { "input": "{\"type\":\"id\",\"name\":\"DNI\"}" } As you can see, the input field contains a ...
Manuelarte's user avatar
  • 1,904
3 votes
1 answer
88 views

I have an Enum like the one below #[serde(rename_all="snake_case")] pub enum Flag { One, Two, Three { value: Option<Decimal>} } I want to match the following json ...
Mindxxxd's user avatar
  • 139
2 votes
1 answer
248 views

Can serde_json::to_writer_pretty indent with tabs rather than 2 spaces? let file = std::fs::File::create(&path).expect("Failed to create json file"); let mut w = BufWriter::new(...
Adamarla's user avatar
  • 874
0 votes
2 answers
188 views

My problem is: I have a function do_something, which expects a vector of objects. The objects can be of different types, but they all have to implement the traits A and B. I declared examples of A and ...
axolotlKing0722's user avatar
0 votes
2 answers
129 views

I have a code to convert json to struct using serde. But, got stuck at a json with dynamic keys. The json will contain the price list. it can vary and will be dynamic {"Price 1":{"price&...
santhoshnsscoe's user avatar
1 vote
2 answers
565 views

Here is a JSON encoded object with a datetime and timezone. I believe this is an ISO 8601 format with 6 digits of precision for fractions of a second. (Microsecond precision.) { "time": &...
user2138149's user avatar
  • 18.6k
0 votes
1 answer
100 views

I apologize for somewhat unclear question, but I can't really phrase it well with one sentence. Below is a toy example illustrating the problem: use serde_json; use serde_json::Value; use serde::{...
executor21's user avatar
  • 4,608
0 votes
1 answer
130 views

I have a struct that I would like to serialize to disk as part of a JSON save file format. The (simplified) structure of the struct is like this: pub struct Effect { pub source: Source, pub ...
Derek Thurn's user avatar
  • 15.5k
1 vote
1 answer
382 views

Here is a Rust playground link with what I have so far. I am working on a Rust project where the serialization/deserialization MUST be interoperable with a C# project. I have these two structs that ...
Jonathan Saraco's user avatar

1
2 3 4 5
20