Closed dcampbell24 closed 3 weeks ago
The de/serialization behavior here is actually implemented in the underlying cookie_store crate. It is true the behavior there is line-oriented (serializing each cookie individually). The crate provides some methods that abstract over the serialization method, with the intent of supporting other formats such as the curl cookie file format and the like. In practice, JSON is the only target format that is used (AFAIK).
That being said, I wouldn't want to change the existing behavior of these methods as this would be breaking for current users/serialized cookie sets. I would be happy to review a PR (on cookie_store) introducing alternative serializations, however.
I created a pull request with some ideas.
You can't parse the cookies with
let cookies: serde_json::Value = serde_json::from_str(&data).unwrap();
, because you store the cookies in an invalid json format. Why not just stick the cookies in an Array?