How do I parse and store the deserialized data in a JObject kind of Object in System.Text.Json. I read a few articles which said using JsonSerializer.Deserialize.Parse method but there isn't any such method. I am trying to do the following:
public class JsonPerson
{
public string FirstName { get; set; }
public string LastName { get; set; }
public int Age { get; set; }
}
var json="";//set json string
var test = System.Text.Json.JsonSerializer.Deserialize<JsonPerson>(json);//Deserialize json
Jobject could be queried to support random access and enumeration.And if you want to use alternative property in System.Text.Json. As
Bruce said,JsonDocument is equivalent.Did you make error or have anything confused by using it?
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
7 Points
24 Posts
What is JObject alternative in System.Text.Json?
Oct 05, 2019 03:12 PM|Test1233@|LINK
How do I parse and store the deserialized data in a JObject kind of Object in System.Text.Json. I read a few articles which said using JsonSerializer.Deserialize.Parse method but there isn't any such method. I am trying to do the following:
All-Star
53574 Points
13316 Posts
Re: What is JObject alternative in System.Text.Json?
Oct 05, 2019 03:24 PM|bruce (sqlwork.com)|LINK
The JsonDocument is the equivalent but lower level
https://docs.microsoft.com/en-us/dotnet/api/system.text.json.jsondocument?view=netcore-3.0
Participant
1878 Points
1002 Posts
MVP
Re: What is JObject alternative in System.Text.Json?
Oct 06, 2019 07:53 AM|maherjendoubi|LINK
Hi,
https://devblogs.microsoft.com/dotnet/try-the-new-system-text-json-apis/
Best regards,
Maher
Blog : https://maherjendoubi.io
Participant
1060 Points
350 Posts
Re: What is JObject alternative in System.Text.Json?
Oct 07, 2019 02:58 AM|Rena Ni|LINK
Hi Test1233@,
You could deserialize data like below:
Jobject could be queried to support random access and enumeration.And if you want to use alternative property in System.Text.Json. As Bruce said,JsonDocument is equivalent.Did you make error or have anything confused by using it?
Reference:
https://docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-0#jsondocument
Best Regards,
Rena
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.