I need my json string to format
[{"key":"1","keyvalue":"a"},{"key":"2","keyvalue":"b"}]
How do I get the map function to serialize the json string into key value pairs?
[{"key":"1","keyvalue":"a"},{"key":"2","keyvalue":"b"}]
B4X:
Server Code:
<Serializable> _
Public Class cKeyItem
Private m_key As String
Private m_keyValue As String
PublicProperty key() AsString
Get
Return m_key
End Get
Set(value As String)
m_key = value
End Set
EndProperty
Public Property keyValue() As String
Get
Return m_keyValue
End Get
Set(value As String)
m_keyValue = value
End Set
EndProperty
EndClass
<WebMethod()> _
Sub Save(sJSON as string)
Dim jSearializer As System.Web.Script.Serialization.JavaScriptSerializer = New System.Web.Script.Serialization.JavaScriptSerializer()
Dim objItemList = jSearializer.Deserialize(Of List(Of cKeyItem))(sJSON)
Dim oKeyItem As cKeyItem
For Each oKeyItem In objItemList
sRetVal = sRetVal & oKeyItem.key & "=" & oKeyItem.keyValue
Next
End Sub
How do I get the map function to serialize the json string into key value pairs?
B4X:
Dim sJSONString As String
Dim oJSONGenerator As JSONGenerator
oJSONGenerator.Initialize2(oKeyValueList)
sJSONString=oJSONGenerator.ToString
Last edited: