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
Add Data In Json FIle
WhatsApp
Manish Pipaliya
Apr 10
2015
1.2
k
0
1
<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
Up Next
Add Data In Json FIle