?
Solved

How do I get a json list into the proper VB.NET class

Posted on 2010-08-23
14
Medium Priority
?
1,005 Views
Last Modified: 2013-11-08
I've been struggling trying to get the following json string into .net classes
This is my first attempt at trying to read json strings and deserializers etc.
The string comes from the Etsy API2 where a list of listings on that site can be retrieved.
It consists of several results of listings.  Listings has many properties
An example of the full output is

 jsonstr2 = "{""count"":93,""results"":[{""listing_id"":45291928,""state"":""active"",""user_id"":8483376,""ti ...

This has many more properties which I will not bore you with here.
I know the basic json into class works because when I use the single listing string

jsonstr2 = "{""listing_id"":45291928,""state"":""active"",""user_id"  ...

and the following code

Dim EtsyListing As Listingv2
EtsyListing = JSONHelper.Deserialize(Of Listingv2)(jsonstr2)
Dim temp9 As String = Etsy.user_ID

    Public Class JSONHelper
        Public Shared Function Deserialize(Of T)(ByVal json As String) As T
            Dim serializer As New       System.Runtime.Serialization.Json.DataContractJsonSerializer(GetType(T))
            Using Stream As New MemoryStream(New UTF8Encoding().GetBytes(json))
                Return (serializer.ReadObject(Stream))
            End Using
        End Function
    End Class

which puts it into the listingv2 class everything works.

When I try to have several list by using this code:
            Dim Listings As ListingCollections
            Lisitings = JSONHelper.Deserialize(Of ListingCollections)(jsonstr)
            Dim temp9 As Integer = Listings.results.Count
            Dim temp11 As String = Listings.results(1).URL

only the first list is in the collection, even though there should be 3.  When I try to access lthese, of course it fails stating that I've exceeded the index.

The problem appears to be the listing collection class which I have as the following:

Imports System.IO
Imports System.Text
Imports System.Xml.Serialization
Imports System.Runtime.Serialization
Imports System.Collections.Generic


<DataContract()> _
Public Class ListingCollections
    Implements IEnumerable, IEnumerator

#Region "Public Properties"

    Private _Etsylistings As List(Of Listingv2)
    <DataMember(Name:="results")> _
    Public Property EtsyListings() As List(Of Listingv2)
        Get
            Return _EtsyListings
        End Get
        Set(ByVal value As List(Of Listingv2))
            _EtsyListings = value
        End Set
    End Property

    Private _totcount As Integer
    <DataMember(Name:="count")> _
    Public Property totcount() As Integer
        Get
            Return _totcount
        End Get
        Set(ByVal value As Integer)
            _totcount = value
        End Set
    End Property

End Class

The initial count in jsonstr2 is also placed correctly.  Only the multiple Etsy Listings are not retrieved correctly.  It appears that I've written the listingcollection class incorrectly.  

Any help appreciated.





0
Comment
Question by:Zimbug4
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 4
14 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 33507354
You've an example here : http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/Q_26387568.html#a33387877
<< A list of row >>

Where's your DataContract << Listingv2 >> ?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33507358
If possible post a full json string in code snipet (click on the link Code)
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33514299
Here an example of Console application, which write the third state element value in the following Json (check the DataContract << Listingv2 >>) :


{
    "count": 93,
    "results": [
        {
            "listing_id": 45291928,
            "state": "active",
            "user_id": 8483376
        },
        {
            "listing_id": 45291928,
            "state": "active",
            "user_id": 8483376
        },
        {
            "listing_id": 20100824,
            "state": "Zimbug4",
            "user_id": 20100824
        }
    ]
}

Open in new window

0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 82

Expert Comment

by:leakim971
ID: 33514320
ConsoleApplication1 :


Imports System.IO
Imports System.Text
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Json

Module Module1

    Sub Main()
        Dim json As String = "{""count"":93,""results"":[{""listing_id"":45291928,""state"":""active"",""user_id"":8483376},{""listing_id"":45291928,""state"":""active"",""user_id"":8483376},{""listing_id"":20100824,""state"":""Zimbug4"",""user_id"":20100824}]"
        Dim lstCollections As New ListingCollections()
        Dim ms As New MemoryStream(Encoding.UTF8.GetBytes(json))
        Dim ser As New DataContractJsonSerializer(lstCollections.GetType())
        lstCollections = TryCast(ser.ReadObject(ms), ListingCollections)
        Console.WriteLine("state value of the third json element from results is : " & lstCollections.EtsyListings.Item(2).state)
        ms.Close()
    End Sub

    <DataContract()> _
    Public Class ListingCollections
        Private _EtsyListings As List(Of Listingv2)
        Private _totcount As Integer

        <DataMember(Name:="results")> _
        Public Property EtsyListings() As List(Of Listingv2)
            Get
                Return _EtsyListings
            End Get
            Set(ByVal value As List(Of Listingv2))
                _EtsyListings = value
            End Set
        End Property

        <DataMember(Name:="count")> _
        Public Property totcount() As Integer
            Get
                Return _totcount
            End Get
            Set(ByVal value As Integer)
                _totcount = value
            End Set
        End Property

        Public Sub New()
        End Sub

        Public Sub New(ByVal EtsyListings As List(Of Listingv2), ByVal totcount As Integer)
            Me._EtsyListings = EtsyListings
            Me._totcount = totcount
        End Sub

    End Class

    <DataContract()> _
    Public Class Listingv2
        Private _listing_id As Integer
        Private _state As String
        Private _user_id As Integer

        <DataMember(Name:="listing_id")> _
        Public Property listing_id() As Integer
            Get
                Return _listing_id
            End Get
            Set(ByVal value As Integer)
                _listing_id = value
            End Set
        End Property

        <DataMember(Name:="state")> _
        Public Property state() As String
            Get
                Return _state
            End Get
            Set(ByVal value As String)
                _state = value
            End Set
        End Property

        <DataMember(Name:="user_id")> _
        Public Property user_id() As Integer
            Get
                Return _user_id
            End Get
            Set(ByVal value As Integer)
                _user_id = value
            End Set
        End Property

        Public Sub New()
        End Sub

        Public Sub New(ByVal listing_id As Integer, ByVal state As String, ByVal user_id As Integer)
            Me._listing_id = listing_id
            Me._state = state
            Me._user_id = user_id
        End Sub

    End Class

End Module

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
ID: 33514633
A web page, asp.net, calling a web service (which one is in the same vs project) :


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script language="javascript" type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script language="javascript" type="text/javascript">
    $(document).ready(function () {
        $("#<%= but.ClientID %>").click(function(event) {
            event.preventDefault();
            $.ajax({
                type: "POST",
                url: "WebService.asmx/ReceiveEtsy",
                dataType: "json",
                data: "{\"json\":\"{\\\"count\\\":93,\\\"results\\\":[{\\\"listing_id\\\":45291928,\\\"state\\\":\\\"active\\\",\\\"user_id\\\": 8483376},{\\\"listing_id\\\":45291928,\\\"state\\\":\\\"active\\\",\\\"user_id\\\": 8483376},{\\\"listing_id\\\":123456,\\\"state\\\":\\\"Zimbug4\\\",\\\"user_id\\\": 20100824}]}\"}",
                contentType: "application/json; charset=utf-8",
                success: function (data) {
                    for (var j in data) {
                        alert(data[j]);
                    }
                },
                error: function (data) {
                    alert("bad news : \n\n" + data.responseText);
                }
            })
        });
    });
</script>
</head>
<body>
<form runat="server">
    <asp:Button ID="but" runat="server" Text="button" ></asp:Button>
</form>
</body>
</html>

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
ID: 33514650
The web service WebService.vb :


Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.IO
Imports System.Text
Imports System.Xml.Serialization
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Json
Imports System.Collections.Generic

<System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class WebService
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    <Script.Services.ScriptMethod(ResponseFormat:=Script.Services.ResponseFormat.Json)> _
    Public Function ReceiveEtsy(ByVal json As String) As String
        Dim lstCollections As New ListingCollections()
        Dim ms As New MemoryStream(Encoding.UTF8.GetBytes(json))
        Dim ser As New DataContractJsonSerializer(lstCollections.GetType())
        lstCollections = TryCast(ser.ReadObject(ms), ListingCollections)
        ms.Close()
        '        Return lstCollections.EtsyListings.ElementAt(2).state
        Return lstCollections.EtsyListings.ElementAt(2).state
    End Function

    <DataContract()> _
    Public Class ListingCollections
        Private _EtsyListings As List(Of Listingv2)
        Private _totcount As Integer

        <DataMember(Name:="results")> _
        Public Property EtsyListings() As List(Of Listingv2)
            Get
                Return _EtsyListings
            End Get
            Set(ByVal value As List(Of Listingv2))
                _EtsyListings = value
            End Set
        End Property

        <DataMember(Name:="count")> _
        Public Property totcount() As Integer
            Get
                Return _totcount
            End Get
            Set(ByVal value As Integer)
                _totcount = value
            End Set
        End Property

        Public Sub New()
        End Sub

        Public Sub New(ByVal EtsyListings As List(Of Listingv2), ByVal totcount As Integer)
            Me._EtsyListings = EtsyListings
            Me._totcount = totcount
        End Sub

    End Class

    <DataContract()> _
    Public Class Listingv2
        Private _listing_id As Integer
        Private _state As String
        Private _user_id As Integer

        <DataMember(Name:="listing_id")> _
        Public Property listing_id() As Integer
            Get
                Return _listing_id
            End Get
            Set(ByVal value As Integer)
                _listing_id = value
            End Set
        End Property

        <DataMember(Name:="state")> _
        Public Property state() As String
            Get
                Return _state
            End Get
            Set(ByVal value As String)
                _state = value
            End Set
        End Property

        <DataMember(Name:="user_id")> _
        Public Property user_id() As Integer
            Get
                Return _user_id
            End Get
            Set(ByVal value As Integer)
                _user_id = value
            End Set
        End Property

        Public Sub New()
        End Sub

        Public Sub New(ByVal listing_id As Integer, ByVal state As String, ByVal user_id As Integer)
            Me._listing_id = listing_id
            Me._state = state
            Me._user_id = user_id
        End Sub

    End Class

End Class

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
ID: 33514666
If you need more help, please post a full Json
0
 

Author Comment

by:Zimbug4
ID: 33517650
I tried you console application which worked great.
The main difference was I was missing the add functions in the class.

I then added the rest of the .NET structure and it no longer works.
There is a clue.  I'm wondering about the embedded array structure?
I've attached the reworked code below


Imports System.IO
Imports System.Text
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Json

Module Module1

    Sub Main()
        Dim json As String = "{""count"":93,""results"":[{""listing_id"":45291928,""state"":""active"",""user_id"":8483376},{""listing_id"":45291928,""state"":""active"",""user_id"":8483376},{""listing_id"":20100824,""state"":""Zimbug4"",""user_id"":20100824}]"
        Dim lstCollections As New ListingCollections()
        Dim ms As New MemoryStream(Encoding.UTF8.GetBytes(json))
        Dim ser As New DataContractJsonSerializer(lstCollections.GetType())
        lstCollections = TryCast(ser.ReadObject(ms), ListingCollections)
        Console.WriteLine("state value of the third json element from results is : " & lstCollections.EtsyListings.Item(2).stats)
        ms.Close()
    End Sub


    <DataContract()> _
    Public Class ListingCollections
        Private _EtsyListings As List(Of Listingv2)
        Private _totcount As Integer

        <DataMember(Name:="results")> _
        Public Property EtsyListings() As List(Of Listingv2)
            Get
                Return _EtsyListings
            End Get
            Set(ByVal value As List(Of Listingv2))
                _EtsyListings = value
            End Set
        End Property

        <DataMember(Name:="count")> _
        Public Property totcount() As Integer
            Get
                Return _totcount
            End Get
            Set(ByVal value As Integer)
                _totcount = value
            End Set
        End Property

        Public Sub New()
        End Sub

        Public Sub New(ByVal EtsyListings As List(Of Listingv2), ByVal totcount As Integer)
            Me._EtsyListings = EtsyListings
            Me._totcount = totcount
        End Sub

    End Class

    <DataContract()> _
    Public Class Listingv2
        Private _listing_id As Integer
        Private _stats As String
        Private _user_id As Integer
        Private _title As String
        Private _description As String
        Private _creation_tsz As Integer
        Private _ending_tsz As Integer
        Private _original_creation_tsz As Integer
        Private _last_modified_tsz As Integer
        Private _price As Decimal?
        Private _currency_code As String
        Private _quantity As Integer
        Private _tags As New ArrayList
        Private _materials As New ArrayList
        Private _featured_rank As Nullable(Of Integer)
        Private _state_tsz As Integer
        Private _hue As Integer
        Private _saturation As Integer
        Private _brightness As Integer
        Private _is_black_and_white As Boolean
        Private _url As String
        Private _views As Integer

        <DataMember(Name:="listing_id")> _
        Public Property listing_id() As Integer
            Get
                Return _listing_id
            End Get
            Set(ByVal value As Integer)
                _listing_id = value
            End Set
        End Property

        <DataMember(Name:="stats")> _
        Public Property stats() As String
            Get
                Return If(_stats Is Nothing, "", _stats)
            End Get
            Set(ByVal value As String)
                _stats = value
            End Set
        End Property

        <DataMember(Name:="user_id")> _
        Public Property user_id() As Integer
            Get
                Return _user_id
            End Get
            Set(ByVal value As Integer)
                _user_id = value
            End Set
        End Property

        <DataMember(Name:="title")> _
        Public Property title() As String
            Get
                Return _title
            End Get
            Set(ByVal value As String)
                _title = value
            End Set
        End Property

        <DataMember(Name:="description")> _
        Public Property description() As String
            Get
                Return _description
            End Get
            Set(ByVal value As String)
                _description = value
            End Set
        End Property

        <DataMember(Name:="creation_tsz")> _
        Public Property creation_tsz() As Integer
            Get
                Return _creation_tsz
            End Get
            Set(ByVal value As Integer)
                _creation_tsz = value
            End Set
        End Property

        <DataMember(Name:="ending_tsz")> _
        Public Property ending_tsz() As Integer
            Get
                Return _ending_tsz
            End Get
            Set(ByVal value As Integer)
                _ending_tsz = value
            End Set
        End Property

        <DataMember(Name:="original_creation_tsz")> _
        Public Property original_creation_tsz() As Integer
            Get
                Return _original_creation_tsz
            End Get
            Set(ByVal value As Integer)
                _original_creation_tsz = value
            End Set
        End Property

        <DataMember(Name:="last_modified_tsz")> _
        Public Property last_modified_tsz() As Integer
            Get
                Return _last_modified_tsz
            End Get
            Set(ByVal value As Integer)
                _last_modified_tsz = value
            End Set
        End Property

        <DataMember(Name:="price")> _
        Public Property price() As Decimal?
            Get
                Return If(_price Is Nothing, 0D, _price)
            End Get
            Set(ByVal value As Decimal?)
                _price = value
            End Set
        End Property

        <DataMember(Name:="currencycode")> _
        Public Property currency_code() As String
            Get
                Return If(_currency_code Is Nothing, "", _currency_code)
            End Get
            Set(ByVal value As String)
                _currency_code = value
            End Set
        End Property

        <DataMember(Name:="quantity")> _
        Public Property quantity() As Integer
            Get
                Return _quantity
            End Get
            Set(ByVal value As Integer)
                _quantity = value
            End Set
        End Property

        <DataMember(Name:="tags")> _
       Public Property Tags() As ArrayList
            Get
                Return _tags
            End Get
            Set(ByVal value As ArrayList)
                _tags = value
            End Set

        End Property
        <DataMember(Name:="materials")> _
        Public Property materials() As ArrayList
            Get
                Return _materials
            End Get
            Set(ByVal value As ArrayList)
                _tags = _materials
            End Set

        End Property

        <DataMember(Name:="featured_rank")> _
        Public Property featured_rank() As Nullable(Of Integer)
            Get
                Return _featured_rank
            End Get
            Set(ByVal value As Nullable(Of Integer))
                _featured_rank = value
            End Set
        End Property

        <DataMember(Name:="state_tsz")> _
        Public Property state_tsz() As Integer
            Get
                Return _state_tsz
            End Get
            Set(ByVal value As Integer)
                _state_tsz = value
            End Set
        End Property

        <DataMember(Name:="hue")> _
        Public Property hue() As Integer
            Get
                Return _hue
            End Get
            Set(ByVal value As Integer)
                _hue = value
            End Set
        End Property

        <DataMember(Name:="sauration")> _
        Public Property saturation() As Integer
            Get
                Return _saturation
            End Get
            Set(ByVal value As Integer)
                _saturation = value
            End Set
        End Property

        <DataMember(Name:="brightness")> _
        Public Property brightness() As Integer
            Get
                Return _brightness
            End Get
            Set(ByVal value As Integer)
                _brightness = value
            End Set
        End Property

        <DataMember(Name:="is_black_and_white")> _
        Public Property is_black_and_white() As Boolean
            Get
                Return _is_black_and_white
            End Get
            Set(ByVal value As Boolean)
                _is_black_and_white = value
            End Set
        End Property

        <DataMember(Name:="url")> _
        Public Property URL() As String
            Get
                Return _url
            End Get
            Set(ByVal value As String)
                _url = value
            End Set
        End Property

        <DataMember(Name:="views")> _
        Public Property views() As Integer
            Get
                Return _views
            End Get
            Set(ByVal value As Integer)
                _views = value
            End Set
        End Property

        Public Sub New()
        End Sub

        Public Sub New(ByVal listing_id As Integer, ByVal state As String, ByVal user_id As Integer)
            Me._listing_id = listing_id
            Me._stats = stats
            Me._user_id = user_id
            Me._title = title
            Me.description = description
            Me._creation_tsz = creation_tsz
            Me._ending_tsz = ending_tsz
            Me._original_creation_tsz = original_creation_tsz
            Me._last_modified_tsz = last_modified_tsz
            Me._price = price
            Me._currency_code = currency_code
            Me._quantity = quantity
            Me._tags = Tags
            Me._materials = materials
            Me._featured_rank = featured_rank
            Me._state_tsz = state_tsz
            Me._hue = hue
            Me._saturation = saturation
            Me._brightness = brightness
            Me._is_black_and_white = is_black_and_white
            Me._url = URL
            Me._views = views

        End Sub

    End Class


I'm also attaching the full json reply containing 3 items in the code snippet



{"count":93,"results":[{"listing_id":52323977,"state":"active","user_id":8483376,"title":"Pleated Fabric HobStyle Pink Floral Handbag","description":"A contemporary red floral  hobo-style bag . This bag has 6 double stitched pleats on the front and back of the handbag. The all cotton lining is reinforced with a heavyweight sew-in interfacing for added strength and durability. There is one interior pocket with zipper. The handles have interfacing and are double stitched on both edges for added strength. The lining is slightly smaller than the outer bag so we can carry lots of stuff without causing the outer fabric to lose it&#39;s shape. The faux belt at the top is adorned with a 1-1\/4&quot; to 1-1\/2&quot; coordinating button. The dimensions of this bag are the following: 17&quot; Height x 19&quot; Width","creation_tsz":1282694471,"ending_tsz":1293166800,"original_creation_tsz":1280106012,"last_modified_tsz":1282694471,"price":"46.00","currency_code":"USD","quantity":1,"tags":["bags_and_purses","medium","purse","hobo","cotton","floral","pink","leaves","red_background","milady_bags"],"materials":["cotton","button","zipper","interfacing"],"shop_section_id":6859524,"featured_rank":null,"state_tsz":1282694471,"hue":0,"saturation":0,"brightness":100,"is_black_and_white":false,"url":"http:\/\/www.etsy.com\/listing\/52323977\/pleated-fabric-hobstyle-pink-floral","views":14},{"listing_id":52258191,"state":"active","user_id":8483376,"title":"Deep Purple and Green Floral Quilted Handbag Tote Combo","description":"The \u201cChristine\u201d is a combination handbag\/tote. It measures 16\u201d wide at the top x 11\u201d tall. The overall height including handles is 19\u201d. The handle length alone is approximately 20\u201d. The bottom of the bag measures 11 \u00bd\u201d wide x 5 \u00bd\u201d deep. This particular bag is made from a beautiful cotton print machine quilted in a 1\u201d diamond pattern by me with a coordinating cotton print fabric for the upper band and handles. The body of the bag is a green and purple floral pattern. The coordinating fabric is a variegated pattern in similar coordinating shades. This bag features two outer pockets, one on each side. Both outer pockets are divided down the middle. The interior is made from the same variegated fabric as the top band and handle featuring six quilted, continuous pockets around the lower interior. The zipper is purse weight with a fabric zipper pull. The bottom of the purse is reinforced with a plastic canvas, fabric covered panel so the handbag will stand up on its own and also support its contents without sagging. ","creation_tsz":1282694471,"ending_tsz":1293166800,"original_creation_tsz":1280018181,"last_modified_tsz":1282694471,"price":"47.00","currency_code":"USD","quantity":1,"tags":["bags_and_purses","purse","tote","medium","floral","cotton","green","purple","outside_pocket"],"materials":["cotton","zipper"],"shop_section_id":6565832,"featured_rank":null,"state_tsz":1282694471,"hue":0,"saturation":0,"brightness":100,"is_black_and_white":false,"url":"http:\/\/www.etsy.com\/listing\/52258191\/deep-purple-and-green-floral-quilted","views":75},{"listing_id":52398504,"state":"active","user_id":8483376,"title":"Cheetah Pleated  Fabric Handbag","description":"A Cheetah fabric handbag for the &quot;wild&quot; animal in you.   The original handbag was a quilted style, where the \u201cKristine\u201d is a non-quilted style. The handles are reinforced with nylon strapping.   I absolutely love this handbag and have several of them for my own personal use. It is so easy to use and carry. It features two separate outer pockets in place of the usual inside pockets making them easily accessible. I no longer have to desperately search for my cell phone when it rings!\r\nThe zipper is recessed down about 1\u201d from the top of the bag. When unzipped, each side pops up against the side of the handbag greatly minimizing the user\u2019s chance of getting scratched or snagged when reaching in. I have never had a problem with either. The specifications for this handbag are listed below.\r\n Dimensions: Inside at Opening: 12&quot;, Outside at Widest: 15&quot;, Handle Height: 11&quot;, Overall Height 22&quot;\r\nPockets: Front Outside Number : 2 (deep);  Latch: Zipper; Batting: Low Loft Polyester; Backing: Cotton","creation_tsz":1282694470,"ending_tsz":1293166800,"original_creation_tsz":1280190435,"last_modified_tsz":1282694470,"price":"39.00","currency_code":"USD","quantity":1,"tags":["bags_and_purses","purse","cotton","medium","cheetah","outside_pockets","milady_bag","milady_creations","brown","zipper"],"materials":["cotton","zipper"],"shop_section_id":6565832,"featured_rank":null,"state_tsz":1282694470,"hue":0,"saturation":0,"brightness":100,"is_black_and_white":false,"url":"http:\/\/www.etsy.com\/listing\/52398504\/cheetah-pleated-fabric-handbag","views":33}]}

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
ID: 33517682
you put stats and not state
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 33517818
you need to set all object or the deserialization will fail with an exception

Your last code with some update

I replaced the ArrayList by : List(Of String))
A use a full json object
renamed stats to state back
Imports System.IO
Imports System.Text
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Json

Module Module1

    Sub Main()
        Dim json As String = "{""count"":93,""results"":[{""listing_id"":45291928,""state"":""active"",""user_id"":8483376,""title"":"""",""description"":"""",""creation_tsz"":20100824,""ending_tsz"":20100824,""original_creation_tsz"":20100824,""last_modified_tsz"":20100824,""price"":1234.56,""currency_code"":"""",""quantity"":1000,""tags"":[],""materials"":[],""featured_rank"":null,""state_tsz"":0,""hue"":0,""saturation"":0,""brightness"":0,""is_black_and_white"":true,""urls"":"""",""views"":9876}]"
        Dim lstCollections As New ListingCollections()
        Dim ms As New MemoryStream(Encoding.UTF8.GetBytes(json))
        Dim ser As New DataContractJsonSerializer(lstCollections.GetType())
        lstCollections = TryCast(ser.ReadObject(ms), ListingCollections)
        Console.WriteLine("state value of the third json element from results is : " & lstCollections.EtsyListings.Item(0).is_black_and_white)
        ms.Close()
    End Sub


    <DataContract()> _
    Public Class ListingCollections
        Private _EtsyListings As List(Of Listingv2)
        Private _totcount As Integer

        <DataMember(Name:="results")> _
        Public Property EtsyListings() As List(Of Listingv2)
            Get
                Return _EtsyListings
            End Get
            Set(ByVal value As List(Of Listingv2))
                _EtsyListings = value
            End Set
        End Property

        <DataMember(Name:="count")> _
        Public Property totcount() As Integer
            Get
                Return _totcount
            End Get
            Set(ByVal value As Integer)
                _totcount = value
            End Set
        End Property

        Public Sub New()
        End Sub

        Public Sub New(ByVal EtsyListings As List(Of Listingv2), ByVal totcount As Integer)
            Me._EtsyListings = EtsyListings
            Me._totcount = totcount
        End Sub

    End Class

    <DataContract()> _
    Public Class Listingv2
        Private _listing_id As Integer
        Private _state As String
        Private _user_id As Integer
        Private _title As String
        Private _description As String
        Private _creation_tsz As Integer
        Private _ending_tsz As Integer
        Private _original_creation_tsz As Integer
        Private _last_modified_tsz As Integer
        Private _price As Decimal?
        Private _currency_code As String
        Private _quantity As Integer
        Private _tags As List(Of String)
        Private _materials As List(Of String)
        Private _featured_rank As Nullable(Of Integer)
        Private _state_tsz As Integer
        Private _hue As Integer
        Private _saturation As Integer
        Private _brightness As Integer
        Private _is_black_and_white As Boolean
        Private _url As String
        Private _views As Integer

        <DataMember(Name:="listing_id")> _
        Public Property listing_id() As Integer
            Get
                Return _listing_id
            End Get
            Set(ByVal value As Integer)
                _listing_id = value
            End Set
        End Property

        <DataMember(Name:="state")> _
        Public Property state() As String
            Get
                Return If(_state Is Nothing, "", _state)
            End Get
            Set(ByVal value As String)
                _state = value
            End Set
        End Property

        <DataMember(Name:="user_id")> _
        Public Property user_id() As Integer
            Get
                Return _user_id
            End Get
            Set(ByVal value As Integer)
                _user_id = value
            End Set
        End Property

        <DataMember(Name:="title")> _
        Public Property title() As String
            Get
                Return _title
            End Get
            Set(ByVal value As String)
                _title = value
            End Set
        End Property

        <DataMember(Name:="description")> _
        Public Property description() As String
            Get
                Return _description
            End Get
            Set(ByVal value As String)
                _description = value
            End Set
        End Property

        <DataMember(Name:="creation_tsz")> _
        Public Property creation_tsz() As Integer
            Get
                Return _creation_tsz
            End Get
            Set(ByVal value As Integer)
                _creation_tsz = value
            End Set
        End Property

        <DataMember(Name:="ending_tsz")> _
        Public Property ending_tsz() As Integer
            Get
                Return _ending_tsz
            End Get
            Set(ByVal value As Integer)
                _ending_tsz = value
            End Set
        End Property

        <DataMember(Name:="original_creation_tsz")> _
        Public Property original_creation_tsz() As Integer
            Get
                Return _original_creation_tsz
            End Get
            Set(ByVal value As Integer)
                _original_creation_tsz = value
            End Set
        End Property

        <DataMember(Name:="last_modified_tsz")> _
        Public Property last_modified_tsz() As Integer
            Get
                Return _last_modified_tsz
            End Get
            Set(ByVal value As Integer)
                _last_modified_tsz = value
            End Set
        End Property

        <DataMember(Name:="price")> _
        Public Property price() As Decimal?
            Get
                Return If(_price Is Nothing, 0D, _price)
            End Get
            Set(ByVal value As Decimal?)
                _price = value
            End Set
        End Property

        <DataMember(Name:="currencycode")> _
        Public Property currency_code() As String
            Get
                Return If(_currency_code Is Nothing, "", _currency_code)
            End Get
            Set(ByVal value As String)
                _currency_code = value
            End Set
        End Property

        <DataMember(Name:="quantity")> _
        Public Property quantity() As Integer
            Get
                Return _quantity
            End Get
            Set(ByVal value As Integer)
                _quantity = value
            End Set
        End Property

        <DataMember(Name:="tags")> _
        Public Property Tags() As List(Of String)
            Get
                Return _tags
            End Get
            Set(ByVal value As List(Of String))
                _tags = value
            End Set

        End Property
        <DataMember(Name:="materials")> _
        Public Property materials() As List(Of String)
            Get
                Return _materials
            End Get
            Set(ByVal value As List(Of String))
                _tags = _materials
            End Set

        End Property

        <DataMember(Name:="featured_rank")> _
        Public Property featured_rank() As Nullable(Of Integer)
            Get
                Return _featured_rank
            End Get
            Set(ByVal value As Nullable(Of Integer))
                _featured_rank = value
            End Set
        End Property

        <DataMember(Name:="state_tsz")> _
        Public Property state_tsz() As Integer
            Get
                Return _state_tsz
            End Get
            Set(ByVal value As Integer)
                _state_tsz = value
            End Set
        End Property

        <DataMember(Name:="hue")> _
        Public Property hue() As Integer
            Get
                Return _hue
            End Get
            Set(ByVal value As Integer)
                _hue = value
            End Set
        End Property

        <DataMember(Name:="sauration")> _
        Public Property saturation() As Integer
            Get
                Return _saturation
            End Get
            Set(ByVal value As Integer)
                _saturation = value
            End Set
        End Property

        <DataMember(Name:="brightness")> _
        Public Property brightness() As Integer
            Get
                Return _brightness
            End Get
            Set(ByVal value As Integer)
                _brightness = value
            End Set
        End Property

        <DataMember(Name:="is_black_and_white")> _
        Public Property is_black_and_white() As Boolean
            Get
                Return _is_black_and_white
            End Get
            Set(ByVal value As Boolean)
                _is_black_and_white = value
            End Set
        End Property

        <DataMember(Name:="url")> _
        Public Property URL() As String
            Get
                Return _url
            End Get
            Set(ByVal value As String)
                _url = value
            End Set
        End Property

        <DataMember(Name:="views")> _
        Public Property views() As Integer
            Get
                Return _views
            End Get
            Set(ByVal value As Integer)
                _views = value
            End Set
        End Property

        Public Sub New()
        End Sub

        Public Sub New(ByVal listing_id As Integer, ByVal state As String, ByVal user_id As Integer, ByVal title As String, ByVal description As String, ByVal creation_tsz As Integer, ByVal ending_tsz As Integer, ByVal original_creation_tsz As Integer, ByVal last_modified_tsz As Integer, ByVal price As Decimal, ByVal currency_code As String, ByVal quantity As Integer, ByVal tags As List(Of String), ByVal materials As List(Of String), ByVal featured_rank As Nullable(Of Integer), ByVal state_tsz As Integer, ByVal hue As Integer, ByVal saturation As Integer, ByVal brightness As Integer, ByVal is_black_and_white As Boolean, ByVal url As String, ByVal views As Integer)
            Me._listing_id = listing_id
            Me._state = state
            Me._user_id = user_id
            Me._title = title
            Me.description = description
            Me._creation_tsz = creation_tsz
            Me._ending_tsz = ending_tsz
            Me._original_creation_tsz = original_creation_tsz
            Me._last_modified_tsz = last_modified_tsz
            Me._price = price
            Me._currency_code = currency_code
            Me._quantity = quantity
            Me._tags = tags
            Me._materials = materials
            Me._featured_rank = featured_rank
            Me._state_tsz = state_tsz
            Me._hue = hue
            Me._saturation = saturation
            Me._brightness = brightness
            Me._is_black_and_white = is_black_and_white
            Me._url = url
            Me._views = views

        End Sub

    End Class

End Module

Open in new window

0
 

Author Comment

by:Zimbug4
ID: 33527316
I tried it and I'm getting the same results.  It reads in the first item but fails to read in the next one.

When the string was smaller in the first example, multiple items worked.
I looked at the json string I posted yesterday and unfortunately I only included one item.  I have a new json string with 3 items attached.

{"count":94,"results":[{"listing_id":54730735,"state":"active","user_id":8483376,"title":"Blue Denim Large Tote or BookBag with Hot Pink Interior and Pocket Organizer","description":"This blue denim bag has a \u201chot pink\u201d denim interior and is super sturdy making it an ideal BOOKBAG. As you can tell by the picture, it holds large notebooks and textbooks without a problem. Additional pockets have been added to the interior. It has a zippered pocket on one side of the interior and a layered set of five additional pockets on the other interior side. The pockets are sized to fit your I-phone, I-pod, checkbook, business cards, calculator, pens\/pencils and other accessories. (Check one of the other bag interiors -&gt; http:\/\/www.etsy.com\/transaction\/32686422 )\r\nThis bag has six double stitched pleats on the front and back of the exterior. The zebra print exterior fabric is an upholstery grade fabric for long lasting durability. The denim lining is reinforced with interfacing and the seams are double stitched for added strength. The handles have been reinforced with webbed strapping and are stitched on both edges for additional strength. The lining is slightly smaller than the outer bag so that the contents will not cause the hobo bag to lose its shape. The faux belt at the top is adorned with a 1-1\/4&quot; to 1-1\/2&quot; coordinating button(s). The dimensions of the bag are 17&quot; in height x 19&quot; in width. The top opening is slightly less than 14&quot;, and the handles are about 22\u201d in length adding around 10\u201d to the overall height.\r\nKeep in mind that any of our hobo style bags can be ordered as a BOOKBAG with the new pocket design!! Simply email or convo me with your choice of fabric(s), and your hobo bookbag will be custom made and shipped in less than a week. ","creation_tsz":1282781056,"ending_tsz":1293253200,"original_creation_tsz":1282781056,"last_modified_tsz":1282781056,"price":"49.00","currency_code":"USD","quantity":1,"tags":["bags_and_purses","tote","cotton","large","book_bag","hot_pink","pocket_organizer","milady_bag","denim","blue","sturdy"],"materials":["cotton","denim","button"],"shop_section_id":6567093,"featured_rank":null,"state_tsz":1282781056,"hue":0,"saturation":0,"brightness":100,"is_black_and_white":false,"url":"http:\/\/www.etsy.com\/listing\/54730735\/blue-denim-large-tote-or-bookbag-with","views":14},{"listing_id":45635610,"state":"active","user_id":8483376,"title":"Wine Cask and Grapes Handmade Fabric Large Tote","description":"This is a quilted fabric tote with grapes on the sides and wine cask in the center. This large tote has two deep outside pockets on the front and back. This is a larger version of the Michelle style. It features four additional inside pockets, one on the front and the other on the back. It is adorned with an ladybug signature charm to bring good luck to you.  This tote is designed to be easy to use, lightweight and large enough to contain all kinds of things at game time.  Dimensions:  {Inside at Opening: 16&quot;, Outside at Widest: 18&quot;, Height: 16&quot;, Overall Height 29&quot; (25&quot; fabric handle)}  Pockets: { Front Outside Number : 1 (deep - 9 1\/2&quot; X 8 1\/2&quot;), Back Outside Number : 1 (deep - 9 1\/2&quot; X 8 1\/2&quot;), Inside Number : 4 }  Decorations\/ Hardware: { Latch: None }  Outer Fabric: { Type: Cotton Grapes & Wine gask, Color: Black, purple, brown, gold, Thread Color: Black & Gold, Batting: Low Loft Polyester, Backing: Cotton}  Inner Lining: { Fabric: Bottom weight Poplin, Color: Black, Brown, Gold, Style: Wine Cask }","creation_tsz":1282778810,"ending_tsz":1293253200,"original_creation_tsz":1272328660,"last_modified_tsz":1282778810,"price":"39.00","currency_code":"USD","quantity":1,"tags":["bags_and_purses","tote","large","quilted","cotton","wine_cask","grapes","tan","brown","milady_creations"],"materials":["cotton","thread"],"shop_section_id":6567093,"featured_rank":null,"state_tsz":1282778810,"hue":0,"saturation":0,"brightness":100,"is_black_and_white":false,"url":"http:\/\/www.etsy.com\/listing\/45635610\/wine-cask-and-grapes-handmade-fabric","views":170},{"listing_id":52928289,"state":"active","user_id":8483376,"title":"One Shoulder Zebra Backpack with Outside Cell Phone Pocket","description":"This over the shoulder backpack is made from a striking black & cream zebra print canvas and black duck cloth on the exterior with a wild pink & black leopard print cotton for the interior lining.  There is one exterior zippered pocket on the back concealed by a zipper flap and adorned with a beaded zipper pull.  A side zipper allows for easy access to the main part of the backpack which contains one other pocket.  This backpack lays flatter to your back than many other backpacks, and the flat, comfortable, over the shoulder strap measures 21\u201d long x 2.75\u201d wide features a front cell phone pocket large enough for an I-phone or equivalent.  The adjustable strap extension measures 22\u201d long x 1\u201d wide.  The overall size of the bag is approximately 10\u201d wide x 16\u201d high x 3\u201d deep.","creation_tsz":1282778794,"ending_tsz":1293253200,"original_creation_tsz":1280797443,"last_modified_tsz":1282778794,"price":"57.00","currency_code":"USD","quantity":1,"tags":["bags_and_purses","backpack","canvas","zebra","shoulder","milady_bags","pink","zipper_pocket","cell_phone_pocket","straps","ergonomic"],"materials":["cotton","zipper","canvas"],"shop_section_id":6573161,"featured_rank":null,"state_tsz":1282778794,"hue":0,"saturation":0,"brightness":100,"is_black_and_white":false,"url":"http:\/\/www.etsy.com\/listing\/52928289\/one-shoulder-zebra-backpack-with-outside","views":81}]}

Open in new window

0
 

Author Comment

by:Zimbug4
ID: 33527471

Ok - There must have been something wrong in some other code due to copy/paste.
I added a 3 list item into the console program as written

It worked !!    Thank-you

For completeness sake here is the whole code ..



    Sub Main()



        Dim Json As String = "{""count"":94,""results"":[{""listing_id"":54730735,""state"":""active"",""user_id"":8483376,""title"":""Blue Denim Large Tote or BookBag with Hot Pink Interior and Pocket Organizer"",""description"":""This blue denim bag has a \u201chot pink\u201d denim interior and is super sturdy making it an ideal BOOKBAG. As you can tell by the picture, it holds large notebooks and textbooks without a problem. Additional pockets have been added to the interior. It has a zippered pocket on one side of the interior and a layered set of five additional pockets on the other interior side. The pockets are sized to fit your I-phone, I-pod, checkbook, business cards, calculator, pens\/pencils and other accessories. (Check one of the other bag interiors -&gt; http:\/\/www.etsy.com\/transaction\/32686422 )\r\nThis bag has six double stitched pleats on the front and back of the exterior. The zebra print exterior fabric is an upholstery grade fabric for long lasting durability. The denim lining is reinforced with interfacing and the seams are double stitched for added strength. The handles have been reinforced with webbed strapping and are stitched on both edges for additional strength. The lining is slightly smaller than the outer bag so that the contents will not cause the hobo bag to lose its shape. The faux belt at the top is adorned with a 1-1\/4&quot; to 1-1\/2&quot; coordinating button(s). The dimensions of the bag are 17&quot; in height x 19&quot; in width. The top opening is slightly less than 14&quot;, and the handles are about 22\u201d in length adding around 10\u201d to the overall height.\r\nKeep in mind that any of our hobo style bags can be ordered as a BOOKBAG with the new pocket design!! Simply email or convo me with your choice of fabric(s), and your hobo bookbag will be custom made and shipped in less than a week. "",""creation_tsz"":1282781056,""ending_tsz"":1293253200,""original_creation_tsz"":1282781056,""last_modified_tsz"":1282781056,""price"":""49.00"",""currency_code"":""USD"",""quantity"":1,""tags"":[""bags_and_purses"",""tote"",""cotton"",""large"",""book_bag"",""hot_pink"",""pocket_organizer"",""milady_bag"",""denim"",""blue"",""sturdy""],""materials"":[""cotton"",""denim"",""button""],""shop_section_id"":6567093,""featured_rank"":null,""state_tsz"":1282781056,""hue"":0,""saturation"":0,""brightness"":100,""is_black_and_white"":false,""url"":""http:\/\/www.etsy.com\/listing\/54730735\/blue-denim-large-tote-or-bookbag-with"",""views"":14},{""listing_id"":45635610,""state"":""active"",""user_id"":8483376,""title"":""Wine Cask and Grapes Handmade Fabric Large Tote"",""description"":""This is a quilted fabric tote with grapes on the sides and wine cask in the center. This large tote has two deep outside pockets on the front and back. This is a larger version of the Michelle style. It features four additional inside pockets, one on the front and the other on the back. It is adorned with an ladybug signature charm to bring good luck to you.  This tote is designed to be easy to use, lightweight and large enough to contain all kinds of things at game time.  Dimensions:  {Inside at Opening: 16&quot;, Outside at Widest: 18&quot;, Height: 16&quot;, Overall Height 29&quot; (25&quot; fabric handle)}  Pockets: { Front Outside Number : 1 (deep - 9 1\/2&quot; X 8 1\/2&quot;), Back Outside Number : 1 (deep - 9 1\/2&quot; X 8 1\/2&quot;), Inside Number : 4 }  Decorations\/ Hardware: { Latch: None }  Outer Fabric: { Type: Cotton Grapes & Wine gask, Color: Black, purple, brown, gold, Thread Color: Black & Gold, Batting: Low Loft Polyester, Backing: Cotton}  Inner Lining: { Fabric: Bottom weight Poplin, Color: Black, Brown, Gold, Style: Wine Cask }"",""creation_tsz"":1282778810,""ending_tsz"":1293253200,""original_creation_tsz"":1272328660,""last_modified_tsz"":1282778810,""price"":""39.00"",""currency_code"":""USD"",""quantity"":1,""tags"":[""bags_and_purses"",""tote"",""large"",""quilted"",""cotton"",""wine_cask"",""grapes"",""tan"",""brown"",""milady_creations""],""materials"":[""cotton"",""thread""],""shop_section_id"":6567093,""featured_rank"":null,""state_tsz"":1282778810,""hue"":0,""saturation"":0,""brightness"":100,""is_black_and_white"":false,""url"":""http:\/\/www.etsy.com\/listing\/45635610\/wine-cask-and-grapes-handmade-fabric"",""views"":171},{""listing_id"":52928289,""state"":""active"",""user_id"":8483376,""title"":""One Shoulder Zebra Backpack with Outside Cell Phone Pocket"",""description"":""This over the shoulder backpack is made from a striking black & cream zebra print canvas and black duck cloth on the exterior with a wild pink & black leopard print cotton for the interior lining.  There is one exterior zippered pocket on the back concealed by a zipper flap and adorned with a beaded zipper pull.  A side zipper allows for easy access to the main part of the backpack which contains one other pocket.  This backpack lays flatter to your back than many other backpacks, and the flat, comfortable, over the shoulder strap measures 21\u201d long x 2.75\u201d wide features a front cell phone pocket large enough for an I-phone or equivalent.  The adjustable strap extension measures 22\u201d long x 1\u201d wide.  The overall size of the bag is approximately 10\u201d wide x 16\u201d high x 3\u201d deep."",""creation_tsz"":1282778794,""ending_tsz"":1293253200,""original_creation_tsz"":1280797443,""last_modified_tsz"":1282778794,""price"":""57.00"",""currency_code"":""USD"",""quantity"":1,""tags"":[""bags_and_purses"",""backpack"",""canvas"",""zebra"",""shoulder"",""milady_bags"",""pink"",""zipper_pocket"",""cell_phone_pocket"",""straps"",""ergonomic""],""materials"":[""cotton"",""zipper"",""canvas""],""shop_section_id"":6573161,""featured_rank"":null,""state_tsz"":1282778794,""hue"":0,""saturation"":0,""brightness"":100,""is_black_and_white"":false,""url"":""http:\/\/www.etsy.com\/listing\/52928289\/one-shoulder-zebra-backpack-with-outside"",""views"":81}]}"
        Dim json2 As String = "{""count"":93,""results"":[{""listing_id"":45291928,""state"":""active"",""user_id"":8483376},{""listing_id"":45291928,""state"":""active"",""user_id"":8483376},{""listing_id"":20100824,""state"":""Zimbug4"",""user_id"":20100824}]"
        Dim lstCollections As New ListingCollections()
        Dim ms As New MemoryStream(Encoding.UTF8.GetBytes(json))
        Dim ser As New DataContractJsonSerializer(lstCollections.GetType())
        lstCollections = TryCast(ser.ReadObject(ms), ListingCollections)
        Console.WriteLine("state value of the first json element from results is : " & lstCollections.EtsyListings.Item(0).URL)
        Console.WriteLine("state value of the third json element from results is : " & lstCollections.EtsyListings.Item(2).URL)
        ms.Close()
    End Sub

    <DataContract()> _
        Public Class ListingCollections
        Private _EtsyListings As List(Of Listingv2)
        Private _totcount As Integer

        <DataMember(Name:="results")> _
        Public Property EtsyListings() As List(Of Listingv2)
            Get
                Return _EtsyListings
            End Get
            Set(ByVal value As List(Of Listingv2))
                _EtsyListings = value
            End Set
        End Property

        <DataMember(Name:="count")> _
        Public Property totcount() As Integer
            Get
                Return _totcount
            End Get
            Set(ByVal value As Integer)
                _totcount = value
            End Set
        End Property

        Public Sub New()
        End Sub

        Public Sub New(ByVal EtsyListings As List(Of Listingv2), ByVal totcount As Integer)
            Me._EtsyListings = EtsyListings
            Me._totcount = totcount
        End Sub

    End Class

    <DataContract()> _
    Public Class Listingv2
        Private _listing_id As Integer
        Private _state As String
        Private _user_id As Integer
        Private _title As String
        Private _description As String
        Private _creation_tsz As Integer
        Private _ending_tsz As Integer
        Private _original_creation_tsz As Integer
        Private _last_modified_tsz As Integer
        Private _price As Decimal?
        Private _currency_code As String
        Private _quantity As Integer
        Private _tags As List(Of String)
        Private _materials As List(Of String)
        Private _featured_rank As Nullable(Of Integer)
        Private _state_tsz As Integer
        Private _hue As Integer
        Private _saturation As Integer
        Private _brightness As Integer
        Private _is_black_and_white As Boolean
        Private _url As String
        Private _views As Integer

        <DataMember(Name:="listing_id")> _
        Public Property listing_id() As Integer
            Get
                Return _listing_id
            End Get
            Set(ByVal value As Integer)
                _listing_id = value
            End Set
        End Property

        <DataMember(Name:="state")> _
        Public Property state() As String
            Get
                Return If(_state Is Nothing, "", _state)
            End Get
            Set(ByVal value As String)
                _state = value
            End Set
        End Property

        <DataMember(Name:="user_id")> _
        Public Property user_id() As Integer
            Get
                Return _user_id
            End Get
            Set(ByVal value As Integer)
                _user_id = value
            End Set
        End Property

        <DataMember(Name:="title")> _
        Public Property title() As String
            Get
                Return _title
            End Get
            Set(ByVal value As String)
                _title = value
            End Set
        End Property

        <DataMember(Name:="description")> _
        Public Property description() As String
            Get
                Return _description
            End Get
            Set(ByVal value As String)
                _description = value
            End Set
        End Property

        <DataMember(Name:="creation_tsz")> _
        Public Property creation_tsz() As Integer
            Get
                Return _creation_tsz
            End Get
            Set(ByVal value As Integer)
                _creation_tsz = value
            End Set
        End Property

        <DataMember(Name:="ending_tsz")> _
        Public Property ending_tsz() As Integer
            Get
                Return _ending_tsz
            End Get
            Set(ByVal value As Integer)
                _ending_tsz = value
            End Set
        End Property

        <DataMember(Name:="original_creation_tsz")> _
        Public Property original_creation_tsz() As Integer
            Get
                Return _original_creation_tsz
            End Get
            Set(ByVal value As Integer)
                _original_creation_tsz = value
            End Set
        End Property

        <DataMember(Name:="last_modified_tsz")> _
        Public Property last_modified_tsz() As Integer
            Get
                Return _last_modified_tsz
            End Get
            Set(ByVal value As Integer)
                _last_modified_tsz = value
            End Set
        End Property

        <DataMember(Name:="price")> _
        Public Property price() As Decimal?
            Get
                Return If(_price Is Nothing, 0D, _price)
            End Get
            Set(ByVal value As Decimal?)
                _price = value
            End Set
        End Property

        <DataMember(Name:="currencycode")> _
        Public Property currency_code() As String
            Get
                Return If(_currency_code Is Nothing, "", _currency_code)
            End Get
            Set(ByVal value As String)
                _currency_code = value
            End Set
        End Property

        <DataMember(Name:="quantity")> _
        Public Property quantity() As Integer
            Get
                Return _quantity
            End Get
            Set(ByVal value As Integer)
                _quantity = value
            End Set
        End Property

        <DataMember(Name:="tags")> _
        Public Property Tags() As List(Of String)
            Get
                Return _tags
            End Get
            Set(ByVal value As List(Of String))
                _tags = value
            End Set

        End Property
        <DataMember(Name:="materials")> _
        Public Property materials() As List(Of String)
            Get
                Return _materials
            End Get
            Set(ByVal value As List(Of String))
                _tags = _materials
            End Set

        End Property

        <DataMember(Name:="featured_rank")> _
        Public Property featured_rank() As Nullable(Of Integer)
            Get
                Return _featured_rank
            End Get
            Set(ByVal value As Nullable(Of Integer))
                _featured_rank = value
            End Set
        End Property

        <DataMember(Name:="state_tsz")> _
        Public Property state_tsz() As Integer
            Get
                Return _state_tsz
            End Get
            Set(ByVal value As Integer)
                _state_tsz = value
            End Set
        End Property

        <DataMember(Name:="hue")> _
        Public Property hue() As Integer
            Get
                Return _hue
            End Get
            Set(ByVal value As Integer)
                _hue = value
            End Set
        End Property

        <DataMember(Name:="sauration")> _
        Public Property saturation() As Integer
            Get
                Return _saturation
            End Get
            Set(ByVal value As Integer)
                _saturation = value
            End Set
        End Property

        <DataMember(Name:="brightness")> _
        Public Property brightness() As Integer
            Get
                Return _brightness
            End Get
            Set(ByVal value As Integer)
                _brightness = value
            End Set
        End Property

        <DataMember(Name:="is_black_and_white")> _
        Public Property is_black_and_white() As Boolean
            Get
                Return _is_black_and_white
            End Get
            Set(ByVal value As Boolean)
                _is_black_and_white = value
            End Set
        End Property

        <DataMember(Name:="url")> _
        Public Property URL() As String
            Get
                Return _url
            End Get
            Set(ByVal value As String)
                _url = value
            End Set
        End Property

        <DataMember(Name:="views")> _
        Public Property views() As Integer
            Get
                Return _views
            End Get
            Set(ByVal value As Integer)
                _views = value
            End Set
        End Property

        Public Sub New()
        End Sub

        Public Sub New(ByVal listing_id As Integer, ByVal state As String, ByVal user_id As Integer, ByVal title As String, ByVal description As String, ByVal creation_tsz As Integer, ByVal ending_tsz As Integer, ByVal original_creation_tsz As Integer, ByVal last_modified_tsz As Integer, ByVal price As Decimal, ByVal currency_code As String, ByVal quantity As Integer, ByVal tags As List(Of String), ByVal materials As List(Of String), ByVal featured_rank As Nullable(Of Integer), ByVal state_tsz As Integer, ByVal hue As Integer, ByVal saturation As Integer, ByVal brightness As Integer, ByVal is_black_and_white As Boolean, ByVal url As String, ByVal views As Integer)
            Me._listing_id = listing_id
            Me._state = state
            Me._user_id = user_id
            Me._title = title
            Me.description = description
            Me._creation_tsz = creation_tsz
            Me._ending_tsz = ending_tsz
            Me._original_creation_tsz = original_creation_tsz
            Me._last_modified_tsz = last_modified_tsz
            Me._price = price
            Me._currency_code = currency_code
            Me._quantity = quantity
            Me._tags = tags
            Me._materials = materials
            Me._featured_rank = featured_rank
            Me._state_tsz = state_tsz
            Me._hue = hue
            Me._saturation = saturation
            Me._brightness = brightness
            Me._is_black_and_white = is_black_and_white
            Me._url = url
            Me._views = views

        End Sub

    End Class

Open in new window

0
 

Author Closing Comment

by:Zimbug4
ID: 33527489
Thank-you!
You were a big help to a real newbie in all of this
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33527595
You're very welcome! Thanks for the points!
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question