Questions tagged [serde-json]

A Rust library for parsing and generating the JSON (JavaScript Object Notation) file format.

A Rust library for parsing and generating the JSON (JavaScript Object Notation) file format. It is built upon Serde, a high performance generic serialization framework.

https://github.com/serde-rs/json

139 questions
-1
votes
1 answer

Access JSON array in serde_json::Value

I have some JSON formatted like this: [ { "name": "jsonvalue" } ] And I want to print it like println!("{:?}", json["name"]);. How do I access a JSON array from a serde_json::Value? I would like to not have to use more variables to…
salmon
  • 31
  • 4
-2
votes
1 answer

Rust Error("missing field `key`") when deserializing to JSON

I already tried this solution but it didn't work. I always get the error Error("missing field key") and want to know how to fix this. Code: pub fn get_user(id: String) -> Data { let cache: RedisCache = RedisCache; let s: String =…
Jan
  • 93
  • 9
-2
votes
1 answer

Why are the results of Go and Rust serialization inconsistent?

The results I want are as follows, but the result of Rust is another. [123 34 66 111 100 121 34 58 34 97 71 86 115 98 71 56 61 34 125] golang sample: type Response struct { Body []byte } func Test_Marshal(t *testing.T) { body :=…
bin zheng
  • 9
  • 1
-2
votes
1 answer

Rust Deserializing JSON

I am having trouble deserializing json data sent from my client. server.rs use std::collections::HashMap; use std::sync::{Arc,Mutex}; use tokio::net::{TcpListener, TcpStream}; use tokio::io::{AsyncWriteExt, AsyncReadExt}; use serde_json::{…
1 2 3
9
10