I have this struct that has a field containing type Option<serde_json::Value>
I want to be able to store any object( i.e. object created by any struct) in that field. The current approach I'm using is to first convert the object to JSON string (using serde_json::to_string
) and then convert it again to serde_json::Value
using serde_json::from_str
.
I'm doing this so that I can send different kinds of JSON requests with arbitrary data.
So, is there a way to convert any serde-serializable object to serde_json::Value
without doing a serde_json::to_string
and serde_json::from_str
?
If I'm going the wrong way with this, please suggest a better one, ty!