2

JSON.Net オブジェクトに逆シリアル化しようとし ている文字列があります。

ネストされた配列にヒットするまで、コードは機能します。次に、空の値を返します。
以下の例では、処理されたオブジェクトをデバッグして表示すると、次のようになります。

ルール:

0:  Will contain all data for the first node (project_number)  
1:  Will contain all data for the second node (agreement_number)  
2:  All fields will be Nothing  

Condition: AND  
Valid: true  

オブジェクト全体を逆シリアル化するにはどうすればよいですか? JSON文字列はライブラリ(https://querybuilder.js.org/)から取得されるため、文字列の作成方法をいじるのをためらっています。

これが私のコードです:

 Dim TestObj = JsonConvert.DeserializeObject(Of List(Of JsonObject))(TestString)

<Serializable()>
Public Class JsonObject
    Public Property condition As String
    Public Property Rules As List(Of Rules)
    Public Property valid As Boolean
End Class

<Serializable()>
Public Class Rules
    Public Property id As String
    Public Property field As String
    Public Property type As String
    Public Property input As String
    Public Property [operator] As String
    Public Property value As String
End Class

Public Property TestString As String = "[
{
   'condition':'AND',
   'rules':[
      {
         'id':'project_number',
         'field':'project_number',
         'type':'string',
         'input':'text',
         'operator':'equal',
         'value':'dfgdfs'
      },
      {
         'id':'agreement_number',
         'field':'agreement_number',
         'type':'string',
         'input':'text',
         'operator':'contains',
         'value':'asdfas'
      },
      {
         'condition':'AND',
         'rules':[
            {
               'id':'division',
               'field':'division',
               'type':'string',
               'input':'select',
               'operator':'in',
               'value':[
                  '0',
                  '11719'
               ]
            },
            {
               'condition':'AND',
               'rules':[
                  {
                     'id':'ta',
                     'field':'ta',
                     'type':'string',
                     'input':'select',
                     'operator':'in',
                     'value':[
                        '24740',
                        '24744'
                     ]
                  }
               ]
            }
         ]
      }
   ],
   'valid':true
}]"
4

1 に答える 1