Json数组列顺序

时间:2013-11-19 13:54:29

标签: arrays json vb.net sorting

我有以下json:

{
"Header": {
    "MCC": "415",
    "FO": "0",
    "REGID": "5"
},
"Contacts": [
    {
        "NAME": "jocelyne",
        "MO": "70123456"
    },
    {
        "NAME": "eliane",
        "MO": "03123456"
    }
] }

我正在使用这种方法将json字符串解析为数据表:

对象类:

Public Class Data
Public Header As Header
Public Contacts As DataTable
End Class

<System.Runtime.Serialization.DataContract()>
Public Class Header
<System.Runtime.Serialization.DataMember(Name:="MCC")>
Public MCC As Integer
<System.Runtime.Serialization.DataMember(Name:="FO")>
Public FO As Integer
<System.Runtime.Serialization.DataMember(Name:="REGID")>
Public RegId As Integer
End Class

.net功能:

    Dim data As New Data
    data = JsonConvert.DeserializeObject(Of Data)(json)
    mcc = data.Header.MCC
    FO = data.Header.FO
    regid = data.Header.RegId
    contactsDT = data.Contacts

我的问题是json中的contacts数组被解析为数据表,其顺序与json中传递的顺序相同...有没有办法改变列的顺序?我的意思是,如果我进入json,请在mo之前说name我需要始终name之前进入数据表mo

有办法吗?

0 个答案:

没有答案