Convert Entry JSON to Entry Model

If you can access the JSON representation of an Entry, then you can convert that JSON to an Entry Model (

This functionality works well as a .NET extension method (

This example uses the Contentstack .NET SDK ( for the following reasons:

The .NET SDKs for all headless CMS products provide similar functionality.

This code uses the SerializerSettings property exposed by ContentstackClient. In this case, there may be nothing relevant in those settings. In other cases, this is a convenient way to avoid initializing a new SerializerSetttings, specifically to add JsonConverters for Modular Blocks and other features, the logic for which I would want to implement only once and in one place. To avoid exposing vendor-specific APIs in your Entry Models, you may want to copy the JObject to a property in your Entry Model after instantiating that Entry Model. Update:

This code also demonstrates how you can retrieve a single simple Field Value from the default Entry Model class. Because every Entry in Contentstack has a Title field, the default Entry Model class has a Title property that you can access. For other properties, you can access values from JSON through the Object property of the default Entry Model class or you may prefer to use the JObject exposed by the ToJson() method of that class, which returns the JObject used to deserialize the JSON to an Entry Model in this example. Optimally, you would use an Entry Model populated implicitly by deserialization rather than accessing the JSON directly in any manner.

2 thoughts on “Convert Entry JSON to Entry Model

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: