Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Json Serialization and Deserialization in ASP.NET
WhatsApp
Manish Pipaliya
May 15
2015
1.2
k
0
0
JSON Serialization
Dim str As String =
""
Dim sr As StreamReader = New StreamReader(
"Path of Json File"
)
str = sr.ReadToEnd()
str = JsonConvert.SerializeObject(str.ToString)
JSON is one kind of data format which is designer for running JavaScript on websites.
JSON Deserialization
Dim emp As New Class1
emp = JsonConvert.DeserializeObject(Of Class1)(str)
Dim cont As New List(Of Class2)
cont = JsonConvert.DeserializeObject(Of List(Of Class2))(emp.employees.ToString)
Response.Write(emp.employees.ToString)
Public Class
Public Class Class1
Public Property fname As String
Public Property employees As Object
End Class
Public Class Class2
Public Property firstName As String
Public Property lastName As String
Public Property data As Object
Public Property phone As Object
End Class
Json File
{
"fname"
:
"Manish"
,
"employees"
: [{
"firstName"
:
"Jatin"
,
"lastName"
:
"Chhodavadiya"
,
"data"
: [{
"id"
: 1,
"text"
:
"Manish"
}],
"phone"
: [{
"offece"
: 9727899812,
"home"
:
"0275281566"
}]
}, {
"firstName"
:
"Ashmita"
,
"lastName"
:
"Devani"
,
"data"
: [{
"id"
: 2,
"text"
:
"Ashmita"
}, {
"id"
: 21,
"text"
:
"Pipaliya"
}],
"phone"
: [{
"offece"
: 9924228344,
"home"
:
"0275285688"
}]
}]
}
Thank you
JSON
Serialization
Up Next
Json Serialization and Deserialization in ASP.NET