We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
How does serde_json serialize Vec into binary rather than an array? Serializing arrays takes up space exponentially.
use serde::{Serialize}; #[derive(Serialize)] struct Test1{ key: Vec<u8> } #[derive(Serialize)] struct Test2{ key: String } fn main() { let data = "xxxxxxxxxxxxxxxx"; let test_vec = Test1 { key: data.as_bytes().to_vec(), }; println!("{}", serde_json::to_vec(&test_vec).unwrap().len()); // 73 let test2 = Test2 { key: data.to_string(), }; println!("{}", serde_json::to_vec(&test2).unwrap().len()); //26 }
The text was updated successfully, but these errors were encountered:
JSON does not have a binary data type. You would need to use a different format if you want binary bytes embedded into it.
Sorry, something went wrong.
No branches or pull requests
How does serde_json serialize Vec into binary rather than an array? Serializing arrays takes up space exponentially.
The text was updated successfully, but these errors were encountered: