Deserialized JSON data returning properties of "Nothing" in VB.NET -


this has been driving me mad past few days. connecting shopify api , downloading json data. have been able deserialize data object using class , code below. however, object "customer" comes properties (as per class) equal "nothing". going on? appreciated!! p.s. should mention using newtonsoft json.net.

partial public class parsedjson     public class customer2         public property accepts_marketing boolean         public property created_at datetime         public property email string         public property first_name string         public property id integer         public property last_name string         public property last_order_id integer         public property multipass_identifier object         public property note object         public property orders_count integer         public property state string         public property total_spent string         public property updated_at datetime         public property verified_email boolean         public property tags string         public property last_order_name string         public property default_address defaultaddress     end class end class  partial public class parsedjson     public class order         public property buyer_accepts_marketing boolean         public property cancel_reason object         public property cancelled_at object         public property cart_token string         public property checkout_token string         public property closed_at object         public property confirmed boolean         public property created_at datetime         public property currency string         public property email string         public property financial_status string         public property fulfillment_status object         public property gateway string         public property id integer         public property landing_site string         public property location_id object         public property name string         public property note string         public property number integer         public property reference object         public property referring_site string         public property source string         public property source_identifier object         public property source_name string         public property source_url object         public property subtotal_price string         public property taxes_included boolean         public property test boolean         public property token string         public property total_discounts string         public property total_line_items_price string         public property total_price string         public property total_price_usd string         public property total_tax string         public property total_weight integer         public property updated_at datetime         public property user_id object         public property browser_ip object         public property landing_site_ref object         public property order_number integer         public property discount_codes object()         public property note_attributes object()         public property processing_method string         public property checkout_id integer         public property tax_lines taxline()         public property tags string         public property line_items lineitem()         public property shipping_lines shippingline()         public property billing_address billingaddress         public property shipping_address shippingaddress         public property fulfillments object()         public property client_details clientdetails         public property customer customer2     end class end class  partial public class parsedjson     public property orders order() end class  ... idea 

now, here implementation code:

        ' calls method getresponsestream return stream associated response.           dim receivestream stream = response.getresponsestream()         dim encode encoding = system.text.encoding.getencoding("utf-8")          ' pipes response stream higher level stream reader required encoding format.            dim readstream new streamreader(receivestream, encode)         dim json_data string = readstream.readtoend()          dim serializer new javascriptserializer()         dim customer parsedjson.customer2 = jsonconvert.deserializeobject(of parsedjson.customer2)(json_data) 

an example of json data can seen @ http://docs.shopify.com/api/order.

code defensively. known issue shopify can provide orders via api have null customer records. if run 1 of those, provide safe defaults. webhooks can receive orders null customers too.

and when fix problem bums out valid customers, you.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -