我正在尝试在vb.net中反序列化JSON字符串。我遇到的问题是(我认为)因为字符串是JSON对象的数组而不是单个JSON对象(说实话,这是一个猜测)。我认为这是因为文件以[和结尾]开头,每对{}之间都有一个逗号。
以下是我正在尝试使用的数据的链接:
我将在问题的底部包含前几行以供参考(它有点长,可以包含在其中)。我正在使用Newtonsoft来解析字符串,但它不起作用:
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
...
Dim json As String = getCrimeData(area)
Dim ser As JObject = JObject.Parse(json)
Dim data As List(Of JToken) = ser.Children().ToList
Dim output As String = ""
For Each item As JProperty In data
item.CreateReader()
Select Case item.Name
End Select
Next
不知道为什么它不能正常工作我得到的错误信息是:
Newtonsoft.Json.JsonReaderException: 'Additional text encountered after finished reading JSON content: ,. Path '', line 1, position 289.'
这里参考的是前几行:
[{"category":"anti-social-behaviour","location_type":"Force","location":{"latitude":"52.961180","street":{"id":1066985,"name":"On or near Deabill Street"},"longitude":"-1.072366"},"context":"","outcome_status":null,"persistent_id":"","id":62066811,"location_subtype":"","month":"2018-01"},{"category":"anti-social-behaviour","location_type":"Force","location":{"latitude":"52.989060","street":{"id":1061254,"name":"On or near Park\/open Space"},"longitude":"-0.988926"},"context":"","outcome_status":null,"persistent_id":"","id":62065597,"location_subtype":"","month":"2018-01"},{"category":"anti-social-behaviour","location_type":"Force","location":{"latitude":"52.958492","street":{"id":1067012,"name":"On or near Mallard Road"},"longitude":"-1.064310"},"context":"","outcome_status":null,"persistent_id":"","id":62066947,"location_subtype":"","month":"2018-01"},{"category":"anti-social-behaviour","location_type":"Force","location":{"latitude":"52.964901","street":{"id":1066875,"name":"On or near Asper Street"},"longitude":"-1.072257"},"context":"","outcome_status":null,"persistent_id":"","id":62065125,"location_subtype":"","month":"2018-01"},{"category":"anti-social-behaviour","location_type":"Force","location":{"latitude":"53.010153","street":{"id":1070264,"name":"On or near Old Tannery Drive"},"longitude":"-0.997808"},"context":"","outcome_status":null,"persistent_id":"","id":62065476,"location_subtype":"","month":"2018-01"},{"category":"anti-social-behaviour","location_type":"Force","location":{"latitude":"52.987829","street":{"id":1068825,"name":"On or near Supermarket"},"longitude":"-1.036609"},"context":"","outcome_status":null,"persistent_id":"","id":62065402,"location_subtype":"","month":"2018-01"},