JSON.NET使用VB.NET反序列化,值为'stop'

时间:2015-07-26 13:52:26

标签: json vb.net json.net

我正在使用VB.NET反序列化JSON字符串。我正在使用JSON.NET并创建了一个与JsonConvert.DeserializeObject函数一起使用的自定义类。我唯一的问题是通过JSON字符串传来的值之一叫做'stop'。这导致VB.NET无法编译,因为您无法声明名称为“stop”的值。当我将'stop'的值更改为其他值时,不再从JSON字符串中读取'stop'值中的数据。我一直试图找出如何解决这个问题,但是如果没有更改JSON字符串响应,我很遗憾无法做到这一点,我已经做到了。任何帮助都将非常感激。

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

2 个答案:

答案 0 :(得分:1)

更改停止属性的名称

<JsonProperty("stop")> _
Public Property anythingButStop As String

答案 1 :(得分:1)

加入Arthurs&#39;答案,

VB代码就是这样的。

$obj = new ParseObject("ObjectClassName");
$obj->setAssociativeArray("relationFieldName", array('__type' => 'Pointer', 'className' => 'relationClassName', 'objectId' => 'relationObjId'));

这是.net fiddle link