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


Prompt Engineering For Agentic Systems
07/08/2025

 

Introducing a Github repository that delves into ways of constructing prompts that squeeze performance out when building AI Agents 

 



TIOBE - Two To Rule Them All
16/07/2025

The July Tiobe index is out and it isn't particularly interesting until you notice that it confirms the standard model of programming -  code is written in Python and C and everything else is jus [ ... ]


More News

pico book

 

Comments




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