You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi all, as a personal project, I am trying to develop a tool for a game that I've been playing called Path of Exile. The tool is intended to scrape market data and display currency trade prices. I am a C++ developer by nature but I want to learn a new language and chose Rust for this project.
The first step is to scrape item information to build a list of available items. I've done it for the most part, with one exception. So here is an example of the json object that I want to deserialize: { "id": "exa", "text": "Exalted Orb", "image": "\/image\/Art\/2DItems\/Currency\/CurrencyAddModToRare.png?v=1745ebafbd533b6f91bccf588ab5efc5" }
I am having trouble deserializing the image value. I am trying to store it into a &str.
It seems like serde is not able to handle escape characters. Can anyone help me with this issue?
The text was updated successfully, but these errors were encountered:
The problem here is that due to the escape sequences, serde_json cannot simply hand out a reference to the original string, since the escape sequences need to be removed while deserializing. You can deserialize this into a String or a Cow<'_, str>. You can also apply #[serde(borrow)] to the latter to get zero copy deserialization when possible.
If it has to be zero copy deserialization you can look into in situ parsing for `serde_json. There is an issue and a pull request for it.
dtolnay
changed the title
Deserializing String with Backslashes :(
JSON string with backslashes does not deserialize into borrowed &str
Jul 5, 2020
Hi all, as a personal project, I am trying to develop a tool for a game that I've been playing called Path of Exile. The tool is intended to scrape market data and display currency trade prices. I am a C++ developer by nature but I want to learn a new language and chose Rust for this project.
The first step is to scrape item information to build a list of available items. I've done it for the most part, with one exception. So here is an example of the json object that I want to deserialize:
{ "id": "exa", "text": "Exalted Orb", "image": "\/image\/Art\/2DItems\/Currency\/CurrencyAddModToRare.png?v=1745ebafbd533b6f91bccf588ab5efc5" }
I am having trouble deserializing the image value. I am trying to store it into a
&str
.It seems like serde is not able to handle escape characters. Can anyone help me with this issue?
The text was updated successfully, but these errors were encountered: