'vb.net how to SerializeObject json

Public Sub JsonCreate()
    Dim thirtynine As New List(Of thirtynine)
    thirtynine.Add(New thirtynine With {
        .text = "agagwgwgagwag"})
    Dim Rootobject As New Rootobject
    With Rootobject
        .tree = {New three With {
                .first = "allan"}}
        .thirtynine = thirtynine.ToArray
    End With

    Dim Settings As New JsonSerializerSettings
    Settings.Formatting = Formatting.Indented
    Settings.NullValueHandling = NullValueHandling.Ignore
    Dim JSON As String = JsonConvert.SerializeObject(Rootobject, Settings)
    MsgBox(JSON)

End Sub

Public Class Rootobject
    <JsonProperty(PropertyName:="3")>
    Public Property tree As three()

    <JsonProperty(PropertyName:="39")>
    Public Property thirtynine As thirtynine()
End Class

Public Class three
    Public Property first As String

End Class

Public Class thirtynine
    Public Property text As String

End Class

this is my output

{ "3": [{ "first": "allan" }], "39": [{ "text": "agagwgwgagwag" }] }

and iwant this output

[{ "3": { "first": "allan" }, "39": { "text": "agagwgwgagwag" } }]

how to change location of []

thanks in advance



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source