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
Add Data In Json FIle
Manish Pipaliya
Apr 10
2015
Code
1.1
k
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
<Services.WebMethod()>
Public Shared Function SaveUser(ByVal id As String, ByVal fName As String, ByVal lName As String) As String
Try
Dim str As String =
""
Dim sr As StreamReader = New StreamReader(
"D:\manish\JsonForm\demo.txt"
)
str = sr.ReadToEnd()
Dim cont As New List(Of Class2)
cont = JsonConvert.DeserializeObject(Of List(Of Class2))(str)
Dim Person As New Class2
Person.id = id
Person.firstName = fName
Person.lastName = lName
cont.Add(Person)
For Each dt In cont
Dim list As New List(Of Class2)
Next
Dim a As String
a = JsonConvert.SerializeObject(cont, Formatting.Indented)
Dim liset As New Class1
sr.Dispose()
Dim sw As StreamWriter = New StreamWriter(
"D:\manish\JsonForm\demo.txt"
)
sw.Write(a)
sw.Dispose()
MsgBox(a)
Catch ex As JsonSerializationException
MsgBox(ex.Message)
End
Try
End
Function
OutPut Of this Code ::
[
{
"id"
:
"11"
,
"firstName"
:
"Manish"
,
"lastName"
:
"Patel"
},
{
"id"
:
"1008"
,
"firstName"
:
"Manish"
,
"lastName"
:
"Poplauu"
},
{
"id"
:
"1"
,
"firstName"
:
"aa"
,
"lastName"
:
"aa"
},
{
"id"
:
"22"
,
"firstName"
:
"ee"
,
"lastName"
:
"ee"
},
{
"id"
:
"1"
,
"firstName"
:
"manish"
,
"lastName"
:
"pilaiui"
},
{
"id"
:
"1002"
,
"firstName"
:
"manish"
,
"lastName"
:
"kanani"
},
{
"id"
:
"1005"
,
"firstName"
:
"Manish"
,
"lastName"
:
"PAtel"
},
{
"id"
:
"1106"
,
"firstName"
:
"Kalpesh"
,
"lastName"
:
"Kanani"
},
{
"id"
:
"aaa"
,
"firstName"
:
"aaa"
,
"lastName"
:
"aaa"
},
{
"id"
:
"101"
,
"firstName"
:
"Mani"
,
"lastName"
:
"Khushi"
}
]
Asp Json