Microsoft Adds Dynamic JSON To Azure Core Library For .NET
Written by Kay Ewbank   
Tuesday, 11 July 2023

Microsoft has added a  new dynamic type to Azure.Core that lets you treat raw JSON like a strongly typed model.

The Azure SDK team says that they are adding protocol methods to Azure SDK client libraries. These are service methods that return a raw Response instead of the typical strongly typed model contained in Response. When calling these methods, it is possible to parse the response content using any JSON parser, such as JsonDocument.

azure

The team says they know that use of existing APIs can result in code that's difficult to read and that may not cleanly express your intent. To solve this problem, the latest release of Azure.Core introduces a way to get response content as a dynamic type. This feature lets you write code at the protocol layer that has the same look and feel as the code you write using a client's convenience layer.

The Content property on Response is a BinaryData type, which has been extended with a new extension method called ToDynamicFromJson. This method returns an instance of a new type called DynamicData that lets you treat JSON content like a strongly typed model. The dynamic JSON that is returned is also mutable, meaning you can modify its properties or even add new properties to it.

The raw response doesn't look the way a model type would look because .NET types don't use camel-case property names, but Microsoft has a "ToDynamicFromJson" method that can be used to make it look more correct. You can pass a propertyNameFormat parameter to the method, telling it what naming convention your JSON property names use. DynamicData will then convert your C# property names to names that match the JSON content. The developers say this is part of a larger design goal they have for the type, which was for it to behave like an Azure SDK model type.

azure

More Information

Getting Started With Azure SDK Documentation

Related Articles

Microsoft Adds New Azure SDKs

.NET 8 Preview 3 Improves ASP.NET Core

Microsoft Launches Azure Blockchain Service

Azure Functions 2 Supports More Platforms

Go SDK For Azure Released

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


Redis Changes License, Rival Fork Launched
03/04/2024

The developers of Redis have announced that they are changing the licensing model for the database. From now on, all future versions of Redis will be released with source-available licenses rather tha [ ... ]



Interact With Virtual Historic Computers
14/04/2024

Alan Turing's ACE computer is a legendary computer that is particularly special for I Programmer - our account of it was the first ever history article on the site when it launched in 2009. Now this i [ ... ]


More News

raspberry pi books

 

Comments




or email your comment to: comments@i-programmer.info