Comments (11)
Geez, took you long enough. I expect more responsiveness from you guys... :-)
from contentful.net.
When you come up with a more comprehensive event model, perhaps it would make sense to have events that overlap on those attributes, then steer people towards using the events for consistency and flexibility in the future. Clearly, you can't stop people from using OnDeserialized
, but you can provide a better overall model and make it clear that it's "more canonical," supported, and resilient to future changes.
from contentful.net.
At the moment this isn't possible, but I understand that this would be convenient. I'm planning on adding some more serialization magic to the GetEntry-methods that would allow for this. Possibly you'd have to implement an interface, but I'm hoping that wouldn't be necessary, simply checking for the existence of a SystemProperties field via reflection should be enough.
from contentful.net.
Proposed solution (mostly so that I remember it myself...): Add the sys property as part of the fields structure before deserializing. That way any serialization attributes added to your POCO class would be respected and you could use custom serialization techniques like json converters or similar.
This would also make sure you don't have to add any custom interface or anything. Just a plain class.
from contentful.net.
This is now added in 0.5.2-alpha.
Documentation will be updated as soon as I get the time.
from contentful.net.
FYI -- I'm not seeing a 0.5.2-alpha out on Nuget. It doesn't show up as an update.
from contentful.net.
It's unlisted still, I think you need to manually install it through the package manager console. Let me know if it doesn't work.
from contentful.net.
Got it. I updated, and it works as expected.
To anyone else looking at this issue in the future: the SystemProperties
property has to be named Sys
. It's deserialized like any other field, so it's specifically matching on the Sys
property name, not the fact that it is of type SystemProperties
, which you might expect.
from contentful.net.
A small addition. The property could actually be named anything, but you would have to decorate it with an JsonProperty attribute to let the serialization engine know how to serialize.
Like this:
public class Term {
[JsonProperty("sys")]
public SystemProperties NotSys { get; set; }
}
Also not in the documentation yet
from contentful.net.
There's always an interesting question of how to delineate the difference between (1) something that is specific to your API, and (2) something that is inherited from an "upstream" API (Newtonsoft JSON serialization, in this instance).
The OnDeserialized
thing from #4 is another example -- from my reading, that's not your thing, that's core to the framework, and probably being called from the Newtonsoft library.
The trick is when people start to think you're just an overlay on top of a something upstream, then they start to depend on that upstream API's doc and capabilities, which gets tricky when you do things to change them, or even swap the upstream API out altogether.
from contentful.net.
Yeah, I agree, the serialization section would mostly be a pointer to the Json.Net documentations, but some "best practices" examples would be nice to have. The OnDeserialized attribute is actually a framework thing, but Json.Net implements it.
from contentful.net.
Related Issues (20)
- Response size too big. Maximum allowed response size: 7340032b HOT 1
- DeserializeWebhookRequestAsync cannot deserialize a Document (rich text content) HOT 3
- Assets are not resolved selectively HOT 10
- Unable to save Rich Text field with BlockData HOT 4
- VerisonMismatch HOT 4
- Quality parameter is discarded for webp images in ImageUrlBuilder HOT 2
- Support ETag in SDK for improved caching HOT 10
- Support Environments HOT 1
- QueryBuilder is hostile to re-use HOT 2
- GetEntriesForLocale() always throws βThe resource could not be found.β
- Newtonsoft 13 - Maxdepth error HOT 1
- [v7.1.0] Serialization Error when using a reference in an Entity HOT 3
- Support quality parameter via ImageTagHelper for webp format HOT 4
- Sync API and UsePreviewApi HOT 4
- Call to GetEntriesRaw not resolving linked entries like JavaScript Sdk HOT 4
- Deserializing response that references same content twice in to different objects throws System.ArgumentException: The value "Type" is not of "Expected type" HOT 4
- Assets returning null for some entries but not others, even when published. HOT 2
- Issue with deserialization with sub/superscript is enabled for RichText HOT 2
- Is there a way to setup a default IContentTypeResolver? HOT 2
- ContentfulClient GetEntries not resolving entries sub props objects correctly in certain scenario HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from contentful.net.