Click here to Skip to main content
15,662,754 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I hope someone of you can help me.
I am receivin JSON and therefore, I created a class.
So far so good :)

Public Class HotelList

    Public Property Size As String

    Public Property ActivePropertyCount As String

    Public Property HotelSummary As List(Of HotelSummary)
End Class

Normally, "HotelSummary" is a list, but in some cases not.
How should I handle that?

Thanks in advance!!!
DamithSL 3-Jun-14 9:01am    
what is the problem? so you have at least one item as HotelSummary?
Member 9500954 3-Jun-14 9:31am    
i am getting an error because it is not a list anymore
Member 9500954 18-Jun-14 10:27am    
Hey! Does anyone of you can help me with this? Would be awesome. Cheers

1 solution

Easiest is to simply always return an array of HotelSummary. If there is only one HotelSummary, then there is just 1 item in the array. When non are returned, it is just an empty list. This makes it a lot easier.

Good luck!
Share this answer
Member 9500954 18-Jun-14 5:37am    

Thanks for your reply!
When I am doing like:
Public Property HotelSummary() HotelSummary


Public Property HotelSummary HotelSummary()

it is still not working!

Do you have any other suggestions?
Thanks a lot for your help and time

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900