-
Couldn't load subscription status.
- Fork 56
fixes the jsonconfig conflicts #241
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
base: dev
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| using System.Collections.Generic; | ||
| using Newtonsoft.Json; | ||
| using Newtonsoft.Json.Serialization; | ||
|
|
||
| namespace Microsoft.Azure.EventHubs.Processor.Options | ||
| { | ||
| /// <summary> | ||
| /// JsonConvert Options | ||
| /// </summary> | ||
| public static class JsonConvertOptions | ||
| { | ||
| /// <summary> | ||
| /// Get the JsonConvert formatting options. so it's not conflicting / dependent upon the user's code. | ||
| /// </summary> | ||
| /// <returns></returns> | ||
| public static JsonSerializerSettings GetOptions() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Allow custom settings as well. Like getter/setter, allow clients to customize their casing. If not set, return the default. |
||
| { | ||
| return new JsonSerializerSettings | ||
| { | ||
| Formatting = Formatting.Indented, | ||
| ContractResolver = new CamelCasePropertyNamesContractResolver(), | ||
| NullValueHandling = NullValueHandling.Ignore | ||
| }; | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this, can you create a static instance of JsonSerializer?
JsonSerializer.Create Method
Creates a new JsonSerializer instance. The JsonSerializer will not use default settings from DefaultSettings.
https://www.newtonsoft.com/json/help/html/M_Newtonsoft_Json_JsonSerializer_Create.htm #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, though you're creating a custom JsonSerializerSettings obj to be able to use the JsonConvert.SerializeObject function.
I just checked another Azure library, they wrapped the entire json settings into a class, resulting pretty much the same I think...
We cannot create a non-default variant of the JsonConvert unfortunately. We could go for the webjob's implementation although we have to add the ContractResolver property otherwise I'm still conflicting with the snake case my code uses. (because they use JsonSerializer.CreateDefault it reuses the default AND the custom settings of the lib) Looking forward to your opinion on this :)