TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Json Serialization and Deserialization in ASP.NET
Manish Pipaliya
May 15
2015
Code
1.1
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
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