2016-12-27 3 views
-1

У меня есть эта строка JSON:Необходимости помогать разбор конкретных JSON

{ 
    "Store": [{ 
     "StoreID": "8643", 
     "IsDeliveryStore": true, 
     "MinDistance": 0.6, 
     "MaxDistance": 0.6, 
     "Phone": "352-505-5557", 
     "AddressDescription": "3581 sw archer rd\nGainesville, FL 32608", 
     "HolidaysDescription": "", 
     "HoursDescription": "Mo-Fr 9:30am-4:00am\nSa-Su 10:00am-4:00am", 
     "ServiceHoursDescription": { 
      "Carryout": "Mo-Fr 9:30am-4:00am\nSa-Su 10:00am-4:00am", 
      "Delivery": "Mo-Fr 9:30am-4:00am\nSa-Su 10:00am-4:00am" 
     }, 
     "IsOnlineCapable": true, 
     "IsOnlineNow": true, 
     "IsNEONow": false, 
     "IsSpanish": true, 
     "LocationInfo": null, 
     "LanguageLocationInfo": { 
      "es": null 
     }, 
     "AllowDeliveryOrders": true, 
     "AllowCarryoutOrders": true, 
     "IsOpen": true, 
     "ServiceIsOpen": { 
      "Carryout": true, 
      "Delivery": true 
     } 
    }, { 
     "StoreID": "3214", 
     "IsDeliveryStore": false, 
     "MinDistance": 2.1, 
     "MaxDistance": 2.1, 
     "Phone": "352-377-4992", 
     "AddressDescription": "3309 W University Ave\nGainesville, FL 32607\nIn Publix Plazza.", 
     "HolidaysDescription": "", 
     "HoursDescription": "Su-Th 10:00am-3:00am\nFr-Sa 10:00am-4:00am", 
     "ServiceHoursDescription": { 
      "Carryout": "Su-Th 10:00am-3:00am\nFr-Sa 10:00am-4:00am", 
      "Delivery": "Su-Th 10:00am-3:00am\nFr-Sa 10:00am-4:00am" 
     }, 
     "IsOnlineCapable": true, 
     "IsOnlineNow": true, 
     "IsNEONow": false, 
     "IsSpanish": false, 
     "LocationInfo": "In Publix Plazza.", 
     "LanguageLocationInfo": { 
      "es": "In Publix Plazza." 
     }, 
     "AllowDeliveryOrders": true, 
     "AllowCarryoutOrders": true, 
     "IsOpen": true, 
     "ServiceIsOpen": { 
      "Carryout": true, 
      "Delivery": true 
     } 
    }, { 
     "StoreID": "3172", 
     "IsDeliveryStore": false, 
     "MinDistance": 2.7, 
     "MaxDistance": 2.7, 
     "Phone": "352-373-8888", 
     "AddressDescription": "5750 SW 75th Ct #40\nGainesville, FL 32608\nIn Park Lane Plaza .", 
     "HolidaysDescription": "", 
     "HoursDescription": "Su-Th 10:00am-1:00am\nFr-Sa 10:00am-2:00am", 
     "ServiceHoursDescription": { 
      "Carryout": "Su-Th 10:00am-1:00am\nFr-Sa 10:00am-2:00am", 
      "Delivery": "Su-Th 10:00am-1:00am\nFr-Sa 10:00am-2:00am" 
     }, 
     "IsOnlineCapable": true, 
     "IsOnlineNow": true, 
     "IsNEONow": false, 
     "IsSpanish": true, 
     "LocationInfo": "In Park Lane Plaza .", 
     "LanguageLocationInfo": { 
      "es": "In Park Lane Plaza ." 
     }, 
     "AllowDeliveryOrders": true, 
     "AllowCarryoutOrders": true, 
     "IsOpen": true, 
     "ServiceIsOpen": { 
      "Carryout": true, 
      "Delivery": true 
     } 
    }, { 
     "StoreID": "5150", 
     "IsDeliveryStore": false, 
     "MinDistance": 2.9, 
     "MaxDistance": 2.9, 
     "Phone": "352-373-2337", 
     "AddressDescription": "2106 Sw 13th St\nGainesville, FL 32608\nIn Domino's Plaza.", 
     "HolidaysDescription": "", 
     "HoursDescription": "Mo-Fr 9:30am-4:00am\nSa-Su 10:00am-4:00am", 
     "ServiceHoursDescription": { 
      "Carryout": "Mo-Fr 9:30am-4:00am\nSa-Su 10:00am-4:00am", 
      "Delivery": "Mo-Fr 9:30am-4:00am\nSa-Su 10:00am-4:00am" 
     }, 
     "IsOnlineCapable": true, 
     "IsOnlineNow": false, 
     "IsNEONow": false, 
     "IsSpanish": false, 
     "SubstitutionStore": "3213", 
     "LocationInfo": "In Domino's Plaza.", 
     "LanguageLocationInfo": { 
      "es": "In Domino's Plaza." 
     }, 
     "AllowDeliveryOrders": true, 
     "AllowCarryoutOrders": true, 
     "IsOpen": true, 
     "ServiceIsOpen": { 
      "Carryout": true, 
      "Delivery": true 
     } 
    }, { 
     "StoreID": "3246", 
     "IsDeliveryStore": false, 
     "MinDistance": 4.5, 
     "MaxDistance": 4.5, 
     "Phone": "352-692-2222", 
     "AddressDescription": "4620 NW 39th Ave\nGainesville, FL\nLocated at Magnolia Park.", 
     "HolidaysDescription": "", 
     "HoursDescription": "Su-Th 10:00am-12:00am\nFr-Sa 10:00am-1:30am", 
     "ServiceHoursDescription": { 
      "Carryout": "Su-Th 10:00am-12:00am\nFr-Sa 10:00am-1:30am", 
      "Delivery": "Su-Th 10:00am-12:00am\nFr-Sa 10:00am-1:30am" 
     }, 
     "IsOnlineCapable": true, 
     "IsOnlineNow": true, 
     "IsNEONow": false, 
     "IsSpanish": true, 
     "LocationInfo": "Located at Magnolia Park.", 
     "LanguageLocationInfo": { 
      "es": "Located at Magnolia Park." 
     }, 
     "AllowDeliveryOrders": true, 
     "AllowCarryoutOrders": true, 
     "IsOpen": true, 
     "ServiceIsOpen": { 
      "Carryout": true, 
      "Delivery": true 
     } 
    }, { 
     "StoreID": "3261", 
     "IsDeliveryStore": false, 
     "MinDistance": 4.7, 
     "MaxDistance": 4.7, 
     "Phone": "352-505-6845", 
     "AddressDescription": "3000 NW 83rd Street\nGainesville, FL 32606\nLocated at the Food Court of Santa Fe College (Bldg R).", 
     "HolidaysDescription": "", 
     "HoursDescription": "Mo-Fr 8:30am-5:00pm\nSa-Su Closed", 
     "ServiceHoursDescription": { 
      "Carryout": "Mo-Fr 8:30am-5:00pm\nSa-Su Closed", 
      "Delivery": "Mo-Fr 8:30am-5:00pm\nSa-Su Closed" 
     }, 
     "IsOnlineCapable": true, 
     "IsOnlineNow": true, 
     "IsNEONow": false, 
     "IsSpanish": true, 
     "LocationInfo": "Located at the Food Court of Santa Fe College (Bldg R).", 
     "LanguageLocationInfo": { 
      "es": "Located at the Food Court of Santa Fe College (Bldg R)." 
     }, 
     "AllowDeliveryOrders": true, 
     "AllowCarryoutOrders": true, 
     "IsOpen": true, 
     "ServiceIsOpen": { 
      "Carryout": true, 
      "Delivery": true 
     } 
    }, { 
     "StoreID": "3213", 
     "IsDeliveryStore": false, 
     "MinDistance": 4.7, 
     "MaxDistance": 4.7, 
     "Phone": "352-373-5555", 
     "AddressDescription": "25 Nw 16th Ave\nGainesville, FL 32601\nOn the north corner of Main Street and NW 16th avenue.", 
     "HolidaysDescription": "", 
     "HoursDescription": "Su-Th 10:00am-3:00am\nFr-Sa 10:00am-4:00am", 
     "ServiceHoursDescription": { 
      "Carryout": "Su-Th 10:00am-3:00am\nFr-Sa 10:00am-4:00am", 
      "Delivery": "Su-Th 10:00am-3:00am\nFr-Sa 10:00am-4:00am" 
     }, 
     "IsOnlineCapable": true, 
     "IsOnlineNow": true, 
     "IsNEONow": false, 
     "IsSpanish": false, 
     "LocationInfo": "On the north corner of Main Street and NW 16th avenue.", 
     "LanguageLocationInfo": { 
      "es": "On the north corner of Main Street and NW 16th avenue." 
     }, 
     "AllowDeliveryOrders": true, 
     "AllowCarryoutOrders": true, 
     "IsOpen": true, 
     "ServiceIsOpen": { 
      "Carryout": true, 
      "Delivery": true 
     } 
    }] 
} 

Я пытаюсь разобрать это, это мой код:

Dim StoreWrapper = JsonConvert.DeserializeObject(Of StoreWrapper)(html) 
Dim AllStores = StoreWrapper.Stores 
Results.Text = AllStores(1).StoreID.ToString 

Public Class StoreWrapper 
    Public Property Store As List(Of Store) 
End Class 
Public Class Store 
Public Property StoreID As String 
Public Property IsDeliveryStore As Boolean 
Public Property MinDistance As Double 
Public Property MaxDistance As Double 
Public Property Phone As String 
Public Property AddressDescription As String 
Public Property HolidaysDescription As String 
Public Property HoursDescription As String 
'Public Property ServiceHoursDescription As String 
Public Property IsOnlineCapable As Boolean 
Public Property IsOnlineNow As Boolean 
Public Property IsNEONow As Boolean 
Public Property IsSpanish As Boolean 
Public Property LocationInfo As String 
'Public Property LanguageLocationInfo As String 
Public Property AllowDeliveryOrders As Boolean 
Public Property AllowCarryoutOrders As Boolean 
Public Property IsOpen As Boolean 
'Public Property ServiceIsOpen As String 
End Class 

Ошибки я получаю:

необработанное исключение типа «System.NullReferenceException» произошло в LocationFinder.exe

Дополнительная информация rmation: Ссылка на объект не установлена ​​в экземпляр объекта.

+0

Пожалуйста, прочитайте [ask] и возьмите [тур], нам нужно знать, в какой строке это происходит. Также найдите время, чтобы узнать, как отформатировать код, чтобы он выглядел как код. – Plutonix

+0

Ваш класс не совсем корректен. Не evenrything является строкой, есть некоторые логические переменные ('true' является bool,' 'true '' будет строкой) и удваивается; это также похоже на то, что вам не хватает некоторых типов: 'ServiceHoursDescription',' LanguageLocationInfo' и 'ServiceIsOpen' являются их собственными типами – Plutonix

+2

Возможный дубликат [Что такое исключение NullReferenceException и как его исправить?] (http: // stackoverflow. com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) –

ответ

0

Необходимое изменение было Public Property Store As List(Of Store)

Спасибо!

Смежные вопросы