I am trying to convert an array into a json array. What I have is:
I have created a class where I declare the fields that I am going to use.
Public Class Response
Public container As Array
Public signature As Tuple(Of Object, String, Integer, String, Object, String)
Sub New()
Me.container = Nothing
Me.signature = Nothing
End Sub
Sub New(ByVal container As Array,
ByVal signature As Tuple(Of Object, String, Integer, String, Object, String))
Me.container = container
Me.signature = signature
End Sub
End Class
And the function where I want to convert them in JSON in order to use:
Public Function GetResponse()
Dim response As New Response
response.container = {"none", False}
response.signature = New Tuple(Of Object, String, Integer, String, Object, String)({10, 10},
"IT", 1, "Testing", {100, 100}, "Test Signature")
Dim JSONString As String = JsonConvert.SerializeObject(response)
Return JSONString
End Function
What I want it to look like is:
{ "container": {
"type": "none",
"single": false
},
"signature": {
"coordinates": {
"x": 10,
"y": 10
},
"location": "IT",
"page": 1,
"reason": "Testing",
"size": {
"height": 100,
"width": 100
},
"value": "Test Signature"
}
}
But what it looks like is:
{
"container": [
"none", false
],
"signature": {
"Item1": [10, 10],
"Item2": "IT",
"Item3": 1,
"Item4": "Testing",
"Item5": [100, 100],
"Item6": "Test Signature"
}
}
I am new to this, I would appriciate any help :) Thanks in advance!
"coordinates"from aTuple? Also, it looks like you wantcontainerto be an object, not an array. Define objects with the shape you want your JSON to have, then fill in the data, and finally serialize.