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

Support serialization for common scenarios #2268

Merged
merged 5 commits into from
Aug 29, 2023

Conversation

brentschmaltz
Copy link
Member

Added to the support 'T' that were available in 6x.
Fix 2038 datetime issue with JwtSecurityToken

If possible, Json will be mapped to one of the following types:
string[], List,,Collection, object[], List, Collection, int[], long[]
Dictionary<string, string>>, Dictionary<string, string[]>, Dictionary<string, List>, Dictionary<string, Collection>
Dictionary<string, object>, Dictionary<string, object[]>

With this change 7 will not be as general as 6x but will help with common scenarios.
A general solution will require a new api.

When calling TryGetPayloadValue the priority is generally:
sting, string[], List, Collection, ...

=================================
Pattern matching is applied when possible.
Json = {“p”:[1,2,3]}
TryGetPayLoadValue<string[]>(“p”) => string[]{“1”,”2”,”3”}

Json = {“p”:”value”}
TryGetPayLoadValue<string[]>(“p”) => string[]{“value”}

Json = {“p”:{”object”:”value”}}
TryGetPayLoadValue(“p”) => “{“object”:”value”}”
This will always return a value if it was the property exists.

=====================================
We still write obj.ToString() when serializing, even if we don't understand the type, as users that are working with Newtosoft.JObject will benefit. We are open to changing this depending on feedback.

}

if (typeof(T) == typeof(object[]))
return (T)(object)new object[] { obj };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we are missing test coverage for these


return (T)(object)items;
}
else if (typeof(T) == typeof(long[]))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have tests for these else ifs?

Copy link
Collaborator

@jennyf19 jennyf19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@brentschmaltz brentschmaltz added this pull request to the merge queue Aug 29, 2023
Merged via the queue into dev7 with commit 59ccc4d Aug 29, 2023
@brentschmaltz brentschmaltz deleted the brentsch/SerializationIssues7 branch August 29, 2023 17:08
brentschmaltz added a commit that referenced this pull request Sep 6, 2023
* Support serialization for common scenarios
fix 2038 datetime issue

* addressed some PR comments

* missed a comma

* removed some commented code

* reorder to fix references

---------

Co-authored-by: Brent Schmaltz <brentsch@hotmail.com>
brentschmaltz added a commit that referenced this pull request Sep 7, 2023
* Support serialization for common scenarios
fix 2038 datetime issue

* addressed some PR comments

* missed a comma

* removed some commented code

* reorder to fix references

---------

Co-authored-by: Brent Schmaltz <brentsch@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants