1
나는 역 직렬화하려고 일부 JSON (https://api.zype.com/consumers/?api_key=qfcR4WWqBws1ezeUHNxTTQl8ucuuP9pW1rMssmQBFUE-AbpPhKp_cY0RnfpY57y5)이 있습니다역 직렬화 JSON
Public Class Consumer
<JsonProperty("email")>
Public Property Email As String
<JsonProperty("stripe_id")>
Public Property StripeId As List(Of String)
<JsonProperty("_id")>
Public Property Id As String
<JsonProperty("_keywords")>
Public Property Keywords As List(Of String)
<JsonProperty("created_at")>
Public Property CreatedOn As Nullable(Of Date)
<JsonProperty("updated_at")>
Public Property UpdatedOn As Nullable(Of Date)
<JsonProperty("deleted_at")>
Public Property DeletedOn As Nullable(Of Date)
<JsonProperty("site_id")>
Public Property SiteId As String
<JsonProperty("subscription_count")>
Public Property SubscriptionCount As Int16
End Class
Public Class ZypeConsumerList
<JsonProperty("response")>
Public Property Consumers As List(Of DanceNetwork.Zype.Consumer)
<JsonProperty("pagination")>
Public Property Pagination As DanceNetwork.Zype.Pagination
End Class
내가 역 직렬화하기 위해 노력하고있어 :
내가 소비자 클래스와 ZypeConsumerList이를 json으로 :
Error converting value "cus_AHtHxKXCwe6MPZ" to type 'System.Collections.Generic.List`1[System.String]'. Path 'response[3].stripe_id', line 1, position 2043.
:
Dim zResponse As ZypeResponse = myCall.Execute(ZypeRestEndpoint.Consumers)
Dim responseBlock As ZypeConsumerList
Dim mySerializerSettings As JsonSerializerSettings = New JsonSerializerSettings()
mySerializerSettings.NullValueHandling = NullValueHandling.Ignore
responseBlock = Newtonsoft.Json.JsonConvert.DeserializeObject(Of ZypeConsumerList)(zResponse.data, mySerializerSettings)
나는이 오류
JSON의 형식이 잘못되어 어디에도 보이지 않으며 위의 값은 실제로 문자열입니다. 내가 뭘 잘못하고 어떻게 해결할 수 있니?
stipe_id가 문자열이 아닌가요? 클래스의 List (Of String)로 정의했습니다. – Lithium
코드가 VB 일 때 왜 C#으로 태그가 붙습니까? –
내가 어떻게 그 클래스를 만들 었는지는 모르겠지만 일반적으로 내가하는 일은 json 결과에 기반한 클래스를 생성하기 위해 http://json2csharp.com/으로 이동하여 자신과 같은 오류를 피하십시오. –