-
Dec 13th, 2015, 08:12 AM
#1
Thread Starter
Addicted Member
How to encode an array in json?
Hi there,
I'm a bit rusty with vb.net and I need your help for encoding this:
Code:
{"monday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"tuesday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"wednesday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"thursday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"friday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"saturday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"sunday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]}}
in json format in vb.net, how you can see this string is already decoded in json but I want know how I can create an array or something like for store the days with the break time. Essentially:
Code:
"monday":{
"start":"09:00",
"end":"18:00",
"breaks":[
{
"start":"11:20",
"end":"11:30"
},
{
"start":"14:30",
"end":"15:00"
}
]
},
"tuesday":{
"start":"09:00",
"end":"18:00",
"breaks":[
{
"start":"11:20",
"end":"11:30"
},
{
"start":"14:30",
"end":"15:00"
}
]
},
Someone could help me to create the array with this contents and convert it into json? Thanks.
-
Dec 13th, 2015, 09:55 AM
#2
Re: How to encode an array in json?
When I create web methods in VB I use Dictionary(Of String, String) for a JSON OBJECT and IList(of String) for a JSON ARRAY.
If the ARRAY is an array of objects then it's an IList(Of Dictionary(Of String, String)).
Kind of like this:
Code:
<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=False)> _
Public Function CtrlService(ByVal ctrloption As String, ByVal ctrlval1 As String _
, ByVal ctrlval2 As String _
, ByVal ctrlval3 As String _
, ByVal ctrlextra As Dictionary(Of String, String) _
, ByVal username As String _
, ByVal sguid As String _
, ByVal source As IList(Of Dictionary(Of String, String))) As String
-
Dec 13th, 2015, 10:18 AM
#3
Thread Starter
Addicted Member
Re: How to encode an array in json?
Originally Posted by szlamany
When I create web methods in VB I use Dictionary(Of String, String) for a JSON OBJECT and IList(of String) for a JSON ARRAY.
If the ARRAY is an array of objects then it's an IList(Of Dictionary(Of String, String)).
Kind of like this:
Code:
<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=False)> _
Public Function CtrlService(ByVal ctrloption As String, ByVal ctrlval1 As String _
, ByVal ctrlval2 As String _
, ByVal ctrlval3 As String _
, ByVal ctrlextra As Dictionary(Of String, String) _
, ByVal username As String _
, ByVal sguid As String _
, ByVal source As IList(Of Dictionary(Of String, String))) As String
What's WebMethod? I just want to know how I can story it in an array or dictionary is the same and made a json that's it. Thanks.
-
Dec 13th, 2015, 10:47 AM
#4
Re: How to encode an array in json?
Don't you represent them as datatypes in VB? I was just demonstrating what data type was a JSON ARRAY.
Show some code so I can see how you are trying to apply this.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|