Hello everyone,
I need to convert a structure to JSON; the idea is not to use external crates, just what the language provides. What can I use?
fn convert_vector_in_json() {
let format = format!(
"[
id:{id}
]",
id = 10
);
println!("{:?}", format.to_string())
}
Code i use
Why are you trying not to use an existing crate?
2 Likes
The project is CLI-based and I'm using rustc; I don't know how to add a crate.
Here 's an example of how you could do it but, as the author of the response says, you would be better off using cargo instead.
Thank you very much; your answers were very helpful.
MOCKBA
March 25, 2026, 12:26am
6
You can look at a simple JSON parser I wrote several months ago. Although it is wrapped in a crate, it has 0 dependencies and can be just inserted in your codebase.
How is the fact that your project is CLI-based relevant to the question?
1 Like