achanda / ipnetwork

A library to work with CIDRs in rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failing to deserialize after converting to `serde_json::value::Value`.

pinkisemils opened this issue · comments

As it stands, deserializing ipnetwork::IpNetwork into a serde_json::value::Value will make it fail to deserialize into ipnetwork::IpNetwork.

let network = IpNetwork::from_str("0.0.0.0/0").unwrap();
let value: serde_json::value::Value = serde_json::from_str(&serde_json::to_string(&network).unwrap()).unwrap();
let _: IpNetwork = serde_json::from_value(value).expect("Actually fails to deserialize");

This might be a serde related issue, but it'd be great if this could be worked around, as currently this issue implies that one can't use ipnetwork::IpNetwork in requests and responses with libraries such as jsonrpc-core.