Partial deserialization.
See original GitHub issueWith v3.1.4, I receive the following XML from an external web source:
<?xml version="1.0" encoding="UTF-8"?>
<pin>
<id type="integer">1309801580</id>
<code>GBCT</code>
<expires-at type="dateTime">2020-05-10T18:52:14Z</expires-at>
<user-id type="integer">231221</user-id>
<client-identifier>8c89f40c-e1f3-45e1-95bc-a45a047ce77f</client-identifier>
<trusted type="boolean">false</trusted>
<auth-token>z6ZM5jeSP19WroEQc2Xy</auth-token>
<auth_token>z6ZM5jeSP19WroEQc2Xy</auth_token>
</pin>
the provided class for it is:
[XmlRoot("pin")]
public sealed class Pin
{
[XmlElement("id")]
public int ID { get; set; }
[XmlElement("code")]
public string Code { get; set; }
[XmlElement("expires-at")]
public DateTime ExpiresAtUTC { get; set; }
[XmlElement("auth-token")]
public string AuthToken { get; set; }
[XmlElement("client-identifier")]
public Guid ClientIdentifier { get; set; }
}
I instantiate the serializer and deserialize with the following. This is a piece of the method who except a generic TReturn type. In this case, a Pin class.
string xml = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
IExtendedXmlSerializer serializer = new ConfigurationContainer().EnableImplicitTypingFromNamespace<Pin>().Create();
using (StringReader stringReader = new StringReader(xml))
{
returnObj = (TReturn)serializer.Deserialize<TReturn>(stringReader);
}
Every property of the resulting class is populated correctly, except AuthToken who is always empty. Is it a bug, or something I do wrong?
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Improving data processing efficiency using partial ...
A significant portion of that processing involves deserializing Thrift structures from serialized bytes on disk. It costs us significant amounts ...
Read more >Deserializing Partial JSON Fragments
Deserializing Partial JSON Fragments ... Often when working with large JSON documents you're only interested in a small fragment of information. This scenario...
Read more >How to do a partial deserialization with Jackson - java
The simplest approach would be using JsonNode : @Data public class FullAddress { private String address; private JsonNode contactInfo; }.
Read more >Can you partial deserialize a Vec? : r/learnrust
Hello, So I am deserializing JSON responses and was wondering if serde can do partial deserialization. For example: Let's say I get back...
Read more >Partial deserialization · Issue #1154 · serde-rs/serde
Is it possible to deserialize structure partially (i.e. something like serde_json::Value but generic across formats).
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Alright I have added a new section to our wiki here, for your review:
https://github.com/ExtendedXmlSerializer/home/wiki/Example-Scenarios#unknown-content
Thank you for the fast answer. I sincerely tried to find this “switch” myself for a few hours. Even now, if I search WithUnknownContent in the API reference, nothing come in the result. I will try this library a little longer, in evaluation mode this time, hoping the documentation will be updated soon. The main reason I use it is for the support of Enums, particularly, I am hoping it support Flags Enums.