0

I am in the process of deserializing a JSON string with VB.NET. I am using JSON.NET and have made a custom class to use with JsonConvert.DeserializeObject function. The only issue I have is one of the values coming through the JSON string is called 'stop'. This causes the VB.NET to not compile, owing to the fact you cannot declare a value with the name 'stop'. When I change the value of 'stop' to something else, the data from the 'stop' value is no longer read from the JSON string. I have been trying to work out how to get around this, but short of changing the JSON string response, which I unfortunately cannot do, I have come up short. Any help would be most appreciated.

Public Class GuideEntry
    Public Property eventId As Integer
    Public Property episodeId As Integer
    Public Property serieslinkId As Integer
    Public Property serieslinkUri As String
    Public Property channelName As String
    Public Property channelUuid As String
    Public Property channelNumber As String
    Public Property start As Integer
    Public Property stop As Integer 'JSON value causing the problem
    Public Property title As String
    Public Property description As String
    Public Property genre As Integer()
    Public Property nextEventId As Integer
    Public Property episodeUri As String
    Public Property episodeNumber As Integer
    Public Property episodeOnscreen As String
    Public Property subtitle As String
    Public Property partNumber As Integer
    Public Property partCount As Integer
    Public Property starRating As Integer
End Class
1

2 Answers 2

1

Change the name of your stop property

<JsonProperty("stop")> _
Public Property anythingButStop As String
Sign up to request clarification or add additional context in comments.

Comments

1

Adding to Arthurs' answer,

VB Code would be something like this.

Public Class GuideEntry
    Public Property eventId As Integer
    Public Property episodeId As Integer
    Public Property serieslinkId As Integer
    Public Property serieslinkUri As String
    Public Property channelName As String
    Public Property channelUuid As String
    Public Property channelNumber As String
    Public Property start As Integer

    <JsonProperty("stop")> _
    Public Property stopValue As Integer 'JSON value causing the problem

    Public Property title As String
    Public Property description As String
    Public Property genre As Integer()
    Public Property nextEventId As Integer
    Public Property episodeUri As String
    Public Property episodeNumber As Integer
    Public Property episodeOnscreen As String
    Public Property subtitle As String
    Public Property partNumber As Integer
    Public Property partCount As Integer
    Public Property starRating As Integer
End Class

Here is .net fiddle link

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.