Suggest me to get the JSON format as describe below using VB.net
var fieldtypes = {
name: { label: 'Name', type: 'text', icon: 'fa-user' },
firstname: { label: 'First name', type: 'text', icon: 'fa-user' },
}
I want to get this format in web-method that call in form of AJAX call. I write the VB.net method for this but it doesn't generate JSON that describe in above.
VB.Net web-method
Public Class FormBuilder
Public Property label() As String
Public Property type() As String
Public Property icon() As String
End Class
Web-method:
Public Shared Function LogsheetDetail(LogMasterID As Integer) As String
Dim sCtrlTag As String = ""
Dim sDataType As String = ""
Dim finalVal As String = ""
Dim oDs As DataSet
Dim frmBuilder As New List(Of FormBuilder)()
Try
oDs = GenUser.TempLogsheetDetails(Conn, LogMasterID)
If oDs.Tables(0).Rows.Count > 0 Then
For i = 0 To oDs.Tables(0).Rows.Count - 1
sDataType = oDs.Tables(0).Rows(i)("data_type").ToString()
Select Case sDataType
Case "Text"
frmBuilder.Add(New FormBuilder() With { _
.label = oDs.Tables(0).Rows(i)("parameter_name").ToString(), _
.type = "text", _
.icon = "fa-user" _
})
End Select
Next
End If
oDs.Dispose()
Catch ex As Exception
Throw New Exception(ex.ToString)
Finally
If Not oDs Is Nothing Then oDs.Dispose()
End Try
Dim objJSSerializer As New System.Web.Script.Serialization.JavaScriptSerializer()
Dim jsonString As String = objJSSerializer.Serialize(frmBuilder)
Return jsonString