以下は私のJSON形式の文字列です
{"AliasName": "ysiCountryInfo", "DataClass": {"説明":"米国 111","コード":"usa","WriteOffTaxPointAdjustment":0,"IndexationRounding":6}}
オブジェクトを以下のクラスにデシリアライズしたい
Option Explicit On Option Strict On
BaseApp.ysiBaseData をインポート Common.DataClasses をインポート システムをインポート
名前空間データクラス
Public Class JSONFormatClass(Of ItemType)
Private _Alias As String
Public Property AliasName() As String
Get
Return _Alias
End Get
Set(ByVal value As String)
_Alias = value
End Set
End Property
Private _DataClass As ItemType
Public Property DataClass() As ItemType
Get
Return _DataClass
End Get
Set(ByVal value As ItemType)
_DataClass = value
End Set
End Property
End Class
名前空間の終了
プロパティ「DataClass」は、「Common.DataClasses」のクラスのタイプです。
そして、このすべてのクラスには、ByRef LoginCredential オブジェクトを受け入れるパラメーター化されたコンストラクターがあります。
そして私のコードは以下の通りです:
ログインデータを新しい ysiLoginData() として暗くする
With loginData
.Server = "xxxxx"
.Platform = ServerType.SqlServer
.Database = "xxxx"
.UserName = "xx"
.Password = "xxxxx"
.DeveloperMode = True
End With
Dim SessionKey を新しい ysiSessionKey(loginData) として
Dim strJSON As String = HttpUtility.UrlDecode(context.Request.Form.ToString())
Dim objJSON As JSONFormatClass(Of ysiCountryInfo) = JsonConvert.DeserializeObject(Of JSONFormatClass(Of ysiCountryInfo))(strJSON)
json 文字列形式: {"AliasName": "ysiCountryInfo", "DataClass": {"Description":"United States 111","Code":"usa","WriteOffTaxPointAdjustment":0,"IndexationRounding":6}}
ここで、「ysiCountryInfo」は、「DataClass」プロパティを変換したいクラス タイプです。「ysiCountryInfo」には、参照による「ysiSessionKey」のパラメーターを必要とするパラメーター化されたコンストラクターがあります。
objCountryInfo を新しい ysiCountryInfo(ysiSessionKey) として薄暗い
行#808でJSONのJsonSerializerInternalReader.jsファイルにエラーが発生しています
object createdObject = contract.ParametrizedConstructor.Invoke(constructorParameters.Values.ToArray());
constructorParameters.Values が Null であるため
この問題をできるだけ早く解決するのを手伝ってください。
ありがとうディレン・ミストリー