Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow camelCase JSON properties to be accessed with PascalCase DynamicJson property accessors #34082

Merged
merged 12 commits into from
Feb 28, 2023

Conversation

annelo-msft
Copy link
Member

@annelo-msft annelo-msft commented Feb 10, 2023

The primary goal of DynamicJson is to help developers work with Azure SDK client protocol methods. These methods essentially take and return raw JSON (RequestContent as an input parameter and Response.Content as output return value), instead of strongly-typed models. DynamicJson lets users treat these values like C# POCOs using the C# dynamic type.

One challenge of this is that Azure APIs use camelCased JSON, where C# style conventions use PascalCased property names.

This PR introduces a feature allowing callers to use PascalCased property names with DynamicJson while maintaining camelCased JSON needed for interaction with the service. It also lets callers configure DynamicJson to use strict casing, and allows service libraries to provide a configuration that works with their service in the event they need to diverge from Azure API guidelines.

In addition, callers can always use DynamicJson indexers to get and set properties with exact string matches on property names.

Addresses #33856

@azure-sdk
Copy link
Collaborator

API change check

APIView has identified API level changes in this PR and created following API reviews.

Azure.Core.Experimental

@annelo-msft annelo-msft changed the title [Draft] Initial work on JsonData property name casing [Draft] Initial work on DynamicJson property name casing Feb 14, 2023
@annelo-msft annelo-msft requested a review from tg-msft as a code owner February 14, 2023 18:19
@annelo-msft annelo-msft changed the title [Draft] Initial work on DynamicJson property name casing Initial work on DynamicJson property name casing Feb 17, 2023
@annelo-msft annelo-msft changed the title Initial work on DynamicJson property name casing Allow camelCase JSON properties to be accessed with PascalCase DynamicJson property accessors Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants