-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jcheng
committed
Apr 19, 2022
1 parent
269e572
commit 7b06dce
Showing
1 changed file
with
1 addition
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7b06dce
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.
The original code used runtime cast on the result of DeserializeObject, which generally does not work in many cases. Below are two examples that show casting can fail. Where the first one is using the JSON from a real test of ours. The fix of this is to use another version: DeserializeObject<T>, which is also demonstrated in the test with success.
`
[Fact]
public void JsonConvertTest()
{
var json =
"{'schemas':['urn:ietf:params:scim:schemas:core:2.0:User','urn:ietf:params:scim:schemas:extension:enterprise:2.0:User'],'externalId':'682448d7-684b-43ea-a58d-f4862cf7ee0f','id':null,'userName':'[email protected]','active':true,'displayName':'cli test simple with email','emails':[{'primary':true,'type':'work','value':'[email protected]'}],'meta':{'resourceType':'User'},'urn:ietf:params:scim:schemas:extension:enterprise:2.0:User':{}}";
}
[Fact]
public void JsonConvertTest2()
{
var json = "[1, 2, 3, 5]";
object list;
}
`