Asked by:
Newtonsoft.Json issue

Question
-
User-125499312 posted
<g class="gr_ gr_20 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="20" data-gr-id="20">i</g> am having an issue converting <g class="gr_ gr_34 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="34" data-gr-id="34">json</g> to an array:
this code works:
Dim jsJson As JsonSerializer = New JsonSerializer
Dim joContent As Newtonsoft.Json.Linq.JObject = Newtonsoft.Json.Linq.JObject.Parse(ResponseFromServer)
Dim jsonResult = (Newtonsoft.Json.JsonConvert.DeserializeObject(Of Object)(ResponseFromServer))the problem arises with
Dim jsonArrRateResponses As Newtonsoft.Json.Linq.JArray = jsonResult("rate_responses")
For Each Rate_Response As Object In jsonArrRateResponses
next
the error is: System.NullReferenceException: Object reference not set to an instance of an object
classes:
Public Class <g class="gr_ gr_85 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="85" data-gr-id="85">Rootobject</g>
Public Property rate_responses() As Rate_Response()
Get
End Get
Set(ByVal value As Rate_Response())
End Set
End Property
End ClassPublic Class Rate_Response
Public Property shipment_id() As String
Get
End Get
Set(ByVal value As String)
End Set
End Property
End Classthx for ur help
Tuesday, August 21, 2018 3:51 PM
All replies
-
User1120430333 posted
public Function GetProjsByUserIdApi(userid As String) as List(of DtoProject) Implements IWebApi.GetProjsByUserIdApi dim dtoprojects = new List(Of DtoProject) dim url = "http://localhost/WebApiVB/api/project/GetProjectsByUserId?userid=" & userid Using webclient As New WebClient dim json = webclient.DownloadString(url) Dim projects = JsonConvert.DeserializeObject(of List(Of DtoProject))(json) dtoprojects = projects End Using Return dtoprojects End Function ============================================================== Public Class DtoProject Public Property ProjectId As Int32 Public Property ClientName As String Public Property ProjectName As String Public Property Technology As String Public Property ProjectType As String Public Property UserId As String Public Property StartDate As DateTime Public Property EndDate As DateTime? Public Property Cost As Decimal End Class
Tuesday, August 21, 2018 9:51 PM -
User-125499312 posted
hi,
thanks for responding.
how would convert the output of GetProjsByUserIdApi to <g class="gr_ gr_87 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation multiReplace" id="87" data-gr-id="87">Newtonsoft.Json.</g>Linq.JArray?
thx for ur help
Wednesday, August 22, 2018 2:44 PM -
User1120430333 posted
yzidell
hi,
thanks for responding.
how would convert the output of GetProjsByUserIdApi to Newtonsoft.Json.Linq.JArray?
thx for ur help
The data is Json being returned from GetProjsByUserIdApi, because the GetProjsByUserIdApi is getting the data from an ASP.NET WebAPI with its default data being Json. So a Json array of DtoProjects is being returned, which is deserialized in the Dtoproject type that is loaded into a List(of Dtoproject) that is a collection.
Wednesday, August 22, 2018 3:54 PM -
User-125499312 posted
my issue is this:
<g class="gr_ gr_33 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="33" data-gr-id="33">i</g> am getting the <g class="gr_ gr_32 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="32" data-gr-id="32">json</g> response and deserializing it.
Dim jsonResult = (Newtonsoft.Json.JsonConvert.DeserializeObject(Of Object)(ResponseFromServer)) 'works fine
next, i want to convert int an array:
Dim jsonArrRateResponses As Newtonsoft.Json.Linq.JArray = jsonResult("rate_responses") 'issue jsonArrRateResponses appears to be null
For Each rate_response As Object In jsonArrRateResponses
Dim objshipment_id As Object = rate_response("shipment_id")'System.NullReferenceException: Object reference not set to an instance of an object
next
can you please help me out here? classes and json are below
classes:
Public Class Rootobject
Public Property carriers() As Carrier()
Get
End Get
Set(ByVal value As Carrier())
End Set
End Property
Public Property rate_responses() As rate_response()
Get
End Get
Set(ByVal value As rate_response())
End Set
End Property
End ClassPublic Class rate_response
Public Property shipment_id() As String
Get
End Get
Set(ByVal value As String)
End Set
End Property
End ClassJSON:
{
"rate_response": {
"rates": [
{
"rate_id": "se-18472510",
"rate_type": "shipment",
"carrier_id": "se-187971",
"shipping_amount": {
"currency": "usd",
"amount": 10.24
},
"insurance_amount": {
"currency": "usd",
"amount": 0
},
"confirmation_amount": {
"currency": "usd",
"amount": 0
},
"other_amount": {
"currency": "usd",
"amount": 0.05
},
"zone": null,
"package_type": null,
"delivery_days": 6,
"guaranteed_service": false,
"estimated_delivery_date": "2018-08-23T23:00:00Z",
"carrier_delivery_days": "Thursday 8/23 by 11:00 PM",
"ship_date": "2018-08-17T00:00:00Z",
"negotiated_rate": false,
"service_type": "UPS® Ground",
"service_code": "ups_ground",
"trackable": true,
"carrier_code": "ups",
"carrier_nickname": "yechiel zidell",
"carrier_friendly_name": "UPS",
"validation_status": "valid",
"warning_messages": [],
"error_messages": []
},
{
"rate_id": "se-18472511",
"rate_type": "shipment",
"carrier_id": "se-187971",
"shipping_amount": {
"currency": "usd",
"amount": 23.75
},
"insurance_amount": {
"currency": "usd",
"amount": 0
},
"confirmation_amount": {
"currency": "usd",
"amount": 0
},
"other_amount": {
"currency": "usd",
"amount": 0.2
},
"zone": null,
"package_type": null,
"delivery_days": 3,
"guaranteed_service": true,
"estimated_delivery_date": "2018-08-22T23:00:00Z",
"carrier_delivery_days": "Wednesday 8/22 by 11:00 PM",
"ship_date": "2018-08-17T00:00:00Z",
"negotiated_rate": false,
"service_type": "UPS 3 Day Select®",
"service_code": "ups_3_day_select",
"trackable": true,
"carrier_code": "ups",
"carrier_nickname": "yechiel zidell",
"carrier_friendly_name": "UPS",
"validation_status": "valid",
"warning_messages": [],
"error_messages": []
},
{
"rate_id": "se-18472512",
"rate_type": "shipment",
"carrier_id": "se-187971",
"shipping_amount": {
"currency": "usd",
"amount": 35.31
},
"insurance_amount": {
"currency": "usd",
"amount": 0
},
"confirmation_amount": {
"currency": "usd",
"amount": 0
},
"other_amount": {
"currency": "usd",
"amount": 0.2
},
"zone": null,
"package_type": null,
"delivery_days": 2,
"guaranteed_service": true,
"estimated_delivery_date": "2018-08-21T10:30:00Z",
"carrier_delivery_days": "Tuesday 8/21 by 10:30 AM",
"ship_date": "2018-08-17T00:00:00Z",
"negotiated_rate": false,
"service_type": "UPS 2nd Day Air AM®",
"service_code": "ups_2nd_day_air_am",
"trackable": true,
"carrier_code": "ups",
"carrier_nickname": "yechiel zidell",
"carrier_friendly_name": "UPS",
"validation_status": "valid",
"warning_messages": [],
"error_messages": []
},
{
"rate_id": "se-18472513",
"rate_type": "shipment",
"carrier_id": "se-187971",
"shipping_amount": {
"currency": "usd",
"amount": 30.55
},
"insurance_amount": {
"currency": "usd",
"amount": 0
},
"confirmation_amount": {
"currency": "usd",
"amount": 0
},
"other_amount": {
"currency": "usd",
"amount": 0.2
},
"zone": null,
"package_type": null,
"delivery_days": 2,
"guaranteed_service": true,
"estimated_delivery_date": "2018-08-21T23:00:00Z",
"carrier_delivery_days": "Tuesday 8/21 by 11:00 PM",
"ship_date": "2018-08-17T00:00:00Z",
"negotiated_rate": false,
"service_type": "UPS 2nd Day Air®",
"service_code": "ups_2nd_day_air",
"trackable": true,
"carrier_code": "ups",
"carrier_nickname": "yechiel zidell",
"carrier_friendly_name": "UPS",
"validation_status": "valid",
"warning_messages": [],
"error_messages": []
},
{
"rate_id": "se-18472514",
"rate_type": "shipment",
"carrier_id": "se-187971",
"shipping_amount": {
"currency": "usd",
"amount": 69.87
},
"insurance_amount": {
"currency": "usd",
"amount": 0
},
"confirmation_amount": {
"currency": "usd",
"amount": 0
},
"other_amount": {
"currency": "usd",
"amount": 0.2
},
"zone": null,
"package_type": null,
"delivery_days": 1,
"guaranteed_service": true,
"estimated_delivery_date": "2018-08-20T15:00:00Z",
"carrier_delivery_days": "Monday 8/20 by 03:00 PM",
"ship_date": "2018-08-17T00:00:00Z",
"negotiated_rate": false,
"service_type": "UPS Next Day Air Saver®",
"service_code": "ups_next_day_air_saver",
"trackable": true,
"carrier_code": "ups",
"carrier_nickname": "yechiel zidell",
"carrier_friendly_name": "UPS",
"validation_status": "valid",
"warning_messages": [],
"error_messages": []
},
{
"rate_id": "se-18472515",
"rate_type": "shipment",
"carrier_id": "se-187971",
"shipping_amount": {
"currency": "usd",
"amount": 109.43
},
"insurance_amount": {
"currency": "usd",
"amount": 0
},
"confirmation_amount": {
"currency": "usd",
"amount": 0
},
"other_amount": {
"currency": "usd",
"amount": 0.2
},
"zone": null,
"package_type": null,
"delivery_days": 1,
"guaranteed_service": true,
"estimated_delivery_date": "2018-08-18T09:30:00Z",
"carrier_delivery_days": "Tomorrow by 09:30 AM",
"ship_date": "2018-08-17T00:00:00Z",
"negotiated_rate": false,
"service_type": "UPS Next Day Air® Early",
"service_code": "ups_next_day_air_early_am",
"trackable": true,
"carrier_code": "ups",
"carrier_nickname": "yechiel zidell",
"carrier_friendly_name": "UPS",
"validation_status": "valid",
"warning_messages": [],
"error_messages": []
},
{
"rate_id": "se-18472516",
"rate_type": "shipment",
"carrier_id": "se-187971",
"shipping_amount": {
"currency": "usd",
"amount": 77.03
},
"insurance_amount": {
"currency": "usd",
"amount": 0
},
"confirmation_amount": {
"currency": "usd",
"amount": 0
},
"other_amount": {
"currency": "usd",
"amount": 0.2
},
"zone": null,
"package_type": null,
"delivery_days": 1,
"guaranteed_service": true,
"estimated_delivery_date": "2018-08-18T12:00:00Z",
"carrier_delivery_days": "Tomorrow by 12:00 PM",
"ship_date": "2018-08-17T00:00:00Z",
"negotiated_rate": false,
"service_type": "UPS Next Day Air®",
"service_code": "ups_next_day_air",
"trackable": true,
"carrier_code": "ups",
"carrier_nickname": "yechiel zidell",
"carrier_friendly_name": "UPS",
"validation_status": "valid",
"warning_messages": [],
"error_messages": []
}
],
"invalid_rates": [],
"rate_request_id": "se-1037005",
"shipment_id": "se-244964253",
"created_at": "2018-08-17T15:53:21.657Z",
"status": "completed",
"errors": []
},
"shipment_id": "se-244964253",
"carrier_id": null,
"service_code": null,
"external_shipment_id": null,
"ship_date": "2018-08-17T00:00:00Z",
"created_at": "2018-08-17T15:53:20.83Z",
"modified_at": "2018-08-17T15:53:20.83Z",
"shipment_status": "pending",
"ship_to": {
"name": "Mickey and Minnie Mouse",
"phone": "714-781-4565",
"company_name": "The Walt Disney Company",
"address_line1": "500 South Buena Vista Street",
"address_line2": null,
"address_line3": null,
"city_locality": "Burbank",
"state_province": "CA",
"postal_code": "91521",
"country_code": "US",
"address_residential_indicator": "unknown"
},
"ship_from": {
"name": "Dade Murphy",
"phone": "512-485-4282",
"company_name": "Zero Cool",
"address_line1": "345 Chambers Street",
"address_line2": "Suite 100",
"address_line3": null,
"city_locality": "New York City",
"state_province": "NY",
"postal_code": "10282",
"country_code": "US",
"address_residential_indicator": "unknown"
},
"warehouse_id": null,
"return_to": {
"name": "Dade Murphy",
"phone": "512-485-4282",
"company_name": "Zero Cool",
"address_line1": "345 Chambers Street",
"address_line2": "Suite 100",
"address_line3": null,
"city_locality": "New York City",
"state_province": "NY",
"postal_code": "10282",
"country_code": "US",
"address_residential_indicator": "unknown"
},
"confirmation": "none",
"customs": null,
"advanced_options": {
"bill_to_account": null,
"bill_to_country_code": null,
"bill_to_party": null,
"bill_to_postal_code": null,
"contains_alcohol": false,
"delivered_duty_paid": false,
"non_machinable": false,
"saturday_delivery": false,
"freight_class": null,
"custom_field1": null,
"custom_field2": null,
"custom_field3": null
},
"insurance_provider": "none",
"tags": [],
"packages": [
{
"package_code": "package",
"weight": {
"value": 1,
"unit": "ounce"
},
"dimensions": {
"unit": "inch",
"length": 0,
"width": 0,
"height": 0
},
"insured_value": {
"currency": "usd",
"amount": 0
},
"label_messages": {
"reference1": null,
"reference2": null,
"reference3": null
}
}
],
"total_weight": {
"value": 1,
"unit": "ounce"
}
}Wednesday, August 22, 2018 4:18 PM -
User475983607 posted
The posted classes do not match the JSON.
Wednesday, August 22, 2018 6:48 PM -
User-125499312 posted
hi <g class="gr_ gr_5 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="5" data-gr-id="5">mgebhard</g>,
could you PLEASE re-write the classes?
<g class="gr_ gr_40 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="40" data-gr-id="40">i</g> would REALLY appreciate it.
THANK YOU
Wednesday, August 22, 2018 6:50 PM -
User475983607 posted
yzidell
could you PLEASE re-write the classes?You can do that yourself. Copy the JSON. Paste the JSON into a Visual Studio class file by clicking the Edit -> Paste Special -> Paste Json as Classes.
It seems that the Newtonsoft deserializer expects a collection type of list. I'm not sure why it does not like the VB array syntax, C# works fine.
Public Class Rootobject Public Property rate_response As Rate_Response Public Property shipment_id As String Public Property carrier_id As Object Public Property service_code As Object Public Property external_shipment_id As Object Public Property ship_date As Date Public Property created_at As Date Public Property modified_at As Date Public Property shipment_status As String Public Property ship_to As Ship_To Public Property ship_from As Ship_From Public Property warehouse_id As Object Public Property return_to As Return_To Public Property confirmation As String Public Property customs As Object Public Property advanced_options As Advanced_Options Public Property insurance_provider As String Public Property tags() As Object Public Property packages() As List(Of Package) Public Property total_weight As Total_Weight End Class Public Class Rate_Response Public Property rates() As List(Of Rate) Public Property invalid_rates() As Object Public Property rate_request_id As String Public Property shipment_id As String Public Property created_at As Date Public Property status As String Public Property errors() As Object End Class Public Class Rate Public Property rate_id As String Public Property rate_type As String Public Property carrier_id As String Public Property shipping_amount As Shipping_Amount Public Property insurance_amount As Insurance_Amount Public Property confirmation_amount As Confirmation_Amount Public Property other_amount As Other_Amount Public Property zone As Object Public Property package_type As Object Public Property delivery_days As Integer Public Property guaranteed_service As Boolean Public Property estimated_delivery_date As Date Public Property carrier_delivery_days As String Public Property ship_date As Date Public Property negotiated_rate As Boolean Public Property service_type As String Public Property service_code As String Public Property trackable As Boolean Public Property carrier_code As String Public Property carrier_nickname As String Public Property carrier_friendly_name As String Public Property validation_status As String Public Property warning_messages() As Object Public Property error_messages() As Object End Class Public Class Shipping_Amount Public Property currency As String Public Property amount As Single End Class Public Class Insurance_Amount Public Property currency As String Public Property amount As Integer End Class Public Class Confirmation_Amount Public Property currency As String Public Property amount As Integer End Class Public Class Other_Amount Public Property currency As String Public Property amount As Single End Class Public Class Ship_To Public Property name As String Public Property phone As String Public Property company_name As String Public Property address_line1 As String Public Property address_line2 As Object Public Property address_line3 As Object Public Property city_locality As String Public Property state_province As String Public Property postal_code As String Public Property country_code As String Public Property address_residential_indicator As String End Class Public Class Ship_From Public Property name As String Public Property phone As String Public Property company_name As String Public Property address_line1 As String Public Property address_line2 As String Public Property address_line3 As Object Public Property city_locality As String Public Property state_province As String Public Property postal_code As String Public Property country_code As String Public Property address_residential_indicator As String End Class Public Class Return_To Public Property name As String Public Property phone As String Public Property company_name As String Public Property address_line1 As String Public Property address_line2 As String Public Property address_line3 As Object Public Property city_locality As String Public Property state_province As String Public Property postal_code As String Public Property country_code As String Public Property address_residential_indicator As String End Class Public Class Advanced_Options Public Property bill_to_account As Object Public Property bill_to_country_code As Object Public Property bill_to_party As Object Public Property bill_to_postal_code As Object Public Property contains_alcohol As Boolean Public Property delivered_duty_paid As Boolean Public Property non_machinable As Boolean Public Property saturday_delivery As Boolean Public Property freight_class As Object Public Property custom_field1 As Object Public Property custom_field2 As Object Public Property custom_field3 As Object End Class Public Class Total_Weight Public Property value As Integer Public Property unit As String End Class Public Class Package Public Property package_code As String Public Property weight As Weight Public Property dimensions As Dimensions Public Property insured_value As Insured_Value Public Property label_messages As Label_Messages End Class Public Class Weight Public Property value As Integer Public Property unit As String End Class Public Class Dimensions Public Property unit As String Public Property length As Integer Public Property width As Integer Public Property height As Integer End Class Public Class Insured_Value Public Property currency As String Public Property amount As Integer End Class Public Class Label_Messages Public Property reference1 As Object Public Property reference2 As Object Public Property reference3 As Object End Class
Wednesday, August 22, 2018 7:37 PM -
User753101303 posted
Please avoid to post the same question multiple times.
So you would go rarther for strongly typed classes as suggested in the other thread as well ?
Wednesday, August 22, 2018 7:41 PM -
User-125499312 posted
hi,
i implemented the classes as you posted - i am still haveing the same issue
System.NullReferenceException: Object reference not set to an instance of an object
my code:
Dim jsonResultRateResponse = JsonConvert.DeserializeObject(Of Object)(strResponseFromServerRateResponse)
Dim jsonArrRateResponses As Json.Linq.JArray = jsonResultRateResponse("Rate_Response")
Thursday, August 23, 2018 3:43 PM -
User475983607 posted
hi,
i implemented the classes as you posted - i am still haveing the same issue
System.NullReferenceException: Object reference not set to an instance of an object
my code:
Dim jsonResultRateResponse = JsonConvert.DeserializeObject(Of Object)(strResponseFromServerRateResponse)
Dim jsonArrRateResponses As Json.Linq.JArray = jsonResultRateResponse("Rate_Response")
Your goal is not clear adn your code does not make sense.
The following code populates the Rootobject object model shown above. I pulling the data from a file, pulling the file content in a string, and deserializing to a ,NET object.
Dim ResponseFromServer As String = System.IO.File.ReadAllText("json1.json") Dim jsonResult = (Newtonsoft.Json.JsonConvert.DeserializeObject(Of Rootobject)(ResponseFromServer))
This syntax drills into the the Rate_Response object.
Dim ratResponse As Rate_Response = jsonResult.rate_response
This syntax creates a JArray
Dim ResponseFromServer As String = System.IO.File.ReadAllText("json1.json") Dim array As Json.Linq.JArray = New Linq.JArray(ResponseFromServer)
Thursday, August 23, 2018 4:27 PM -
User-125499312 posted
hi,
<g class="gr_ gr_20 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="20" data-gr-id="20">i</g> am making progress thanks to your help.
when <g class="gr_ gr_64 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="64" data-gr-id="64">i</g> try to access a child value, <g class="gr_ gr_120 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="120" data-gr-id="120">i</g> get this error:
Cannot access child value on Newtonsoft.Json.Linq.JValue. at Microsoft.VisualBasic.CompilerServices.Symbols.Container.InvokeMethod(Method TargetProcedure, Object[] Arguments, Boolean[] CopyBack, BindingFlags Flags) at Microsoft.VisualBasic.CompilerServices.NewLateBinding.CallMethod(Container BaseReference, String MethodName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, BindingFlags InvocationFlags, Boolean ReportErrors, ResolutionFailure& Failure) at Microsoft.VisualBasic.CompilerServices.NewLateBinding.InternalLateIndexGet(Object Instance, Object[] Arguments, String[] ArgumentNames, Boolean ReportErrors, ResolutionFailure& Failure) at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateIndexGet(Object Instance, Object[] Arguments, String[] ArgumentNames)
Thursday, August 23, 2018 5:45 PM -
User475983607 posted
hi,
i am making progress thanks to your help.
when i try to access a child value, i get this error:
Cannot access child value on Newtonsoft.Json.Linq.JValue. at Microsoft.VisualBasic.CompilerServices.Symbols.Container.InvokeMethod(Method TargetProcedure, Object[] Arguments, Boolean[] CopyBack, BindingFlags Flags) at Microsoft.VisualBasic.CompilerServices.NewLateBinding.CallMethod(Container BaseReference, String MethodName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, BindingFlags InvocationFlags, Boolean ReportErrors, ResolutionFailure& Failure) at Microsoft.VisualBasic.CompilerServices.NewLateBinding.InternalLateIndexGet(Object Instance, Object[] Arguments, String[] ArgumentNames, Boolean ReportErrors, ResolutionFailure& Failure) at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateIndexGet(Object Instance, Object[] Arguments, String[] ArgumentNames)
I have no idea what you're doing without the code. Can you explain the problem you are trying to solve?
Thursday, August 23, 2018 5:51 PM -
User-125499312 posted
sure
<g class="gr_ gr_36 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="36" data-gr-id="36">i</g> am trying to loop thru the array and extract the child values to use them (eg populate a drop-down list)
Dim strShipmentID As String
For Each objRateResponse As Object In jsonArrRateResponses
strShipmentID = objRateResponse("shipment_id")
next
thx for your ongoing help
Thursday, August 23, 2018 5:56 PM -
User475983607 posted
sure
i am trying to loop thru the array and extract the child values to use them (eg populate a drop-down list)
Dim strShipmentID As String
For Each objRateResponse As Object In jsonArrRateResponses
strShipmentID = objRateResponse("shipment_id")
next
thx for your ongoing help
I just don't understand your approach the shipment_id is a property of the reate_response and the root object. Simply use standard VB dot notation to fetch property values.
Dim ResponseFromServer As String = System.IO.File.ReadAllText("json1.json") Dim root As Rootobject = (Newtonsoft.Json.JsonConvert.DeserializeObject(Of Rootobject)(ResponseFromServer)) Console.WriteLine(root.rate_response.shipment_id) Console.WriteLine(root.shipment_id)
Thursday, August 23, 2018 6:07 PM -
User-125499312 posted
<g class="gr_ gr_15 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="15" data-gr-id="15">i</g> a trying it
error
System.NullReferenceException: Object reference not set to an instance of an object
Thursday, August 23, 2018 6:15 PM -
User475983607 posted
i a trying it
error
System.NullReferenceException: Object reference not set to an instance of an object
I assume your JSON source has a bug. You'll need to fix that on your own. I simply took the JSON you posted above and put it in a file and named it json1.json. If you mindlessly copied my code, without putting the JSON in a file, then I would expect a null exception error.
yzidell, you need to put on your developer hat...
Thursday, August 23, 2018 6:29 PM -
User-125499312 posted
this is the result of Dim jsonArrRateResponses As Newtonsoft.Json.Linq.JArray = New Linq.JArray(strResponseFromServerRateResponse)
[ "{\r\n \"rate_response\": {\r\n \"rates\": [\r\n {\r\n \"rate_id\": \"se-19456046\",\r\n \"rate_type\": \"shipment\",\r\n \"carrier_id\": \"se-187971\",\r\n \"shipping_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 10.24\r\n },\r\n \"insurance_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"confirmation_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"other_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.05\r\n },\r\n \"zone\": null,\r\n \"package_type\": null,\r\n \"delivery_days\": 6,\r\n \"guaranteed_service\": false,\r\n \"estimated_delivery_date\": \"2018-08-29T23:00:00Z\",\r\n \"carrier_delivery_days\": \"Wednesday 8/29 by 11:00 PM\",\r\n \"ship_date\": \"2018-08-23T00:00:00Z\",\r\n \"negotiated_rate\": false,\r\n \"service_type\": \"UPS® Ground\",\r\n \"service_code\": \"ups_ground\",\r\n \"trackable\": true,\r\n \"carrier_code\": \"ups\",\r\n \"carrier_nickname\": \"yechiel zidell\",\r\n \"carrier_friendly_name\": \"UPS\",\r\n \"validation_status\": \"valid\",\r\n \"warning_messages\": [],\r\n \"error_messages\": []\r\n },\r\n {\r\n \"rate_id\": \"se-19456047\",\r\n \"rate_type\": \"shipment\",\r\n \"carrier_id\": \"se-187971\",\r\n \"shipping_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 23.75\r\n },\r\n \"insurance_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"confirmation_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"other_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.20\r\n },\r\n \"zone\": null,\r\n \"package_type\": null,\r\n \"delivery_days\": 3,\r\n \"guaranteed_service\": true,\r\n \"estimated_delivery_date\": \"2018-08-28T23:00:00Z\",\r\n \"carrier_delivery_days\": \"Tuesday 8/28 by 11:00 PM\",\r\n \"ship_date\": \"2018-08-23T00:00:00Z\",\r\n \"negotiated_rate\": false,\r\n \"service_type\": \"UPS 3 Day Select®\",\r\n \"service_code\": \"ups_3_day_select\",\r\n \"trackable\": true,\r\n \"carrier_code\": \"ups\",\r\n \"carrier_nickname\": \"yechiel zidell\",\r\n \"carrier_friendly_name\": \"UPS\",\r\n \"validation_status\": \"valid\",\r\n \"warning_messages\": [],\r\n \"error_messages\": []\r\n },\r\n {\r\n \"rate_id\": \"se-19456048\",\r\n \"rate_type\": \"shipment\",\r\n \"carrier_id\": \"se-187971\",\r\n \"shipping_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 35.31\r\n },\r\n \"insurance_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"confirmation_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"other_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.20\r\n },\r\n \"zone\": null,\r\n \"package_type\": null,\r\n \"delivery_days\": 2,\r\n \"guaranteed_service\": true,\r\n \"estimated_delivery_date\": \"2018-08-27T10:30:00Z\",\r\n \"carrier_delivery_days\": \"Monday 8/27 by 10:30 AM\",\r\n \"ship_date\": \"2018-08-23T00:00:00Z\",\r\n \"negotiated_rate\": false,\r\n \"service_type\": \"UPS 2nd Day Air AM®\",\r\n \"service_code\": \"ups_2nd_day_air_am\",\r\n \"trackable\": true,\r\n \"carrier_code\": \"ups\",\r\n \"carrier_nickname\": \"yechiel zidell\",\r\n \"carrier_friendly_name\": \"UPS\",\r\n \"validation_status\": \"valid\",\r\n \"warning_messages\": [],\r\n \"error_messages\": []\r\n },\r\n {\r\n \"rate_id\": \"se-19456049\",\r\n \"rate_type\": \"shipment\",\r\n \"carrier_id\": \"se-187971\",\r\n \"shipping_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 30.55\r\n },\r\n \"insurance_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"confirmation_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"other_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.20\r\n },\r\n \"zone\": null,\r\n \"package_type\": null,\r\n \"delivery_days\": 2,\r\n \"guaranteed_service\": true,\r\n \"estimated_delivery_date\": \"2018-08-25T23:00:00Z\",\r\n \"carrier_delivery_days\": \"Saturday 8/25 by 11:00 PM\",\r\n \"ship_date\": \"2018-08-23T00:00:00Z\",\r\n \"negotiated_rate\": false,\r\n \"service_type\": \"UPS 2nd Day Air®\",\r\n \"service_code\": \"ups_2nd_day_air\",\r\n \"trackable\": true,\r\n \"carrier_code\": \"ups\",\r\n \"carrier_nickname\": \"yechiel zidell\",\r\n \"carrier_friendly_name\": \"UPS\",\r\n \"validation_status\": \"valid\",\r\n \"warning_messages\": [],\r\n \"error_messages\": []\r\n },\r\n {\r\n \"rate_id\": \"se-19456050\",\r\n \"rate_type\": \"shipment\",\r\n \"carrier_id\": \"se-187971\",\r\n \"shipping_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 69.87\r\n },\r\n \"insurance_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"confirmation_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"other_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.20\r\n },\r\n \"zone\": null,\r\n \"package_type\": null,\r\n \"delivery_days\": 1,\r\n \"guaranteed_service\": true,\r\n \"estimated_delivery_date\": \"2018-08-24T15:00:00Z\",\r\n \"carrier_delivery_days\": \"Tomorrow by 03:00 PM\",\r\n \"ship_date\": \"2018-08-23T00:00:00Z\",\r\n \"negotiated_rate\": false,\r\n \"service_type\": \"UPS Next Day Air Saver®\",\r\n \"service_code\": \"ups_next_day_air_saver\",\r\n \"trackable\": true,\r\n \"carrier_code\": \"ups\",\r\n \"carrier_nickname\": \"yechiel zidell\",\r\n \"carrier_friendly_name\": \"UPS\",\r\n \"validation_status\": \"valid\",\r\n \"warning_messages\": [],\r\n \"error_messages\": []\r\n },\r\n {\r\n \"rate_id\": \"se-19456051\",\r\n \"rate_type\": \"shipment\",\r\n \"carrier_id\": \"se-187971\",\r\n \"shipping_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 109.43\r\n },\r\n \"insurance_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"confirmation_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"other_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.20\r\n },\r\n \"zone\": null,\r\n \"package_type\": null,\r\n \"delivery_days\": 1,\r\n \"guaranteed_service\": true,\r\n \"estimated_delivery_date\": \"2018-08-24T08:30:00Z\",\r\n \"carrier_delivery_days\": \"Tomorrow by 08:30 AM\",\r\n \"ship_date\": \"2018-08-23T00:00:00Z\",\r\n \"negotiated_rate\": false,\r\n \"service_type\": \"UPS Next Day Air® Early\",\r\n \"service_code\": \"ups_next_day_air_early_am\",\r\n \"trackable\": true,\r\n \"carrier_code\": \"ups\",\r\n \"carrier_nickname\": \"yechiel zidell\",\r\n \"carrier_friendly_name\": \"UPS\",\r\n \"validation_status\": \"valid\",\r\n \"warning_messages\": [],\r\n \"error_messages\": []\r\n },\r\n {\r\n \"rate_id\": \"se-19456052\",\r\n \"rate_type\": \"shipment\",\r\n \"carrier_id\": \"se-187971\",\r\n \"shipping_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 77.03\r\n },\r\n \"insurance_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"confirmation_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"other_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.20\r\n },\r\n \"zone\": null,\r\n \"package_type\": null,\r\n \"delivery_days\": 1,\r\n \"guaranteed_service\": true,\r\n \"estimated_delivery_date\": \"2018-08-24T10:30:00Z\",\r\n \"carrier_delivery_days\": \"Tomorrow by 10:30 AM\",\r\n \"ship_date\": \"2018-08-23T00:00:00Z\",\r\n \"negotiated_rate\": false,\r\n \"service_type\": \"UPS Next Day Air®\",\r\n \"service_code\": \"ups_next_day_air\",\r\n \"trackable\": true,\r\n \"carrier_code\": \"ups\",\r\n \"carrier_nickname\": \"yechiel zidell\",\r\n \"carrier_friendly_name\": \"UPS\",\r\n \"validation_status\": \"valid\",\r\n \"warning_messages\": [],\r\n \"error_messages\": []\r\n }\r\n ],\r\n \"invalid_rates\": [],\r\n \"rate_request_id\": \"se-1134611\",\r\n \"shipment_id\": \"se-247208589\",\r\n \"created_at\": \"2018-08-23T18:34:30.187Z\",\r\n \"status\": \"completed\",\r\n \"errors\": []\r\n },\r\n \"shipment_id\": \"se-247208589\",\r\n \"carrier_id\": null,\r\n \"service_code\": null,\r\n \"external_shipment_id\": null,\r\n \"ship_date\": \"2018-08-23T00:00:00Z\",\r\n \"created_at\": \"2018-08-23T18:34:29.313Z\",\r\n \"modified_at\": \"2018-08-23T18:34:29.313Z\",\r\n \"shipment_status\": \"pending\",\r\n \"ship_to\": {\r\n \"name\": \"Mickey and Minnie Mouse\",\r\n \"phone\": \"714-781-4565\",\r\n \"company_name\": \"The Walt Disney Company\",\r\n \"address_line1\": \"500 South Buena Vista Street\",\r\n \"address_line2\": null,\r\n \"address_line3\": null,\r\n \"city_locality\": \"Burbank\",\r\n \"state_province\": \"CA\",\r\n \"postal_code\": \"91521\",\r\n \"country_code\": \"US\",\r\n \"address_residential_indicator\": \"unknown\"\r\n },\r\n \"ship_from\": {\r\n \"name\": \"Dade Murphy\",\r\n \"phone\": \"512-485-4282\",\r\n \"company_name\": \"Zero Cool\",\r\n \"address_line1\": \"345 Chambers Street\",\r\n \"address_line2\": \"Suite 100\",\r\n \"address_line3\": null,\r\n \"city_locality\": \"New York City\",\r\n \"state_province\": \"NY\",\r\n \"postal_code\": \"10282\",\r\n \"country_code\": \"US\",\r\n \"address_residential_indicator\": \"unknown\"\r\n },\r\n \"warehouse_id\": null,\r\n \"return_to\": {\r\n \"name\": \"Dade Murphy\",\r\n \"phone\": \"512-485-4282\",\r\n \"company_name\": \"Zero Cool\",\r\n \"address_line1\": \"345 Chambers Street\",\r\n \"address_line2\": \"Suite 100\",\r\n \"address_line3\": null,\r\n \"city_locality\": \"New York City\",\r\n \"state_province\": \"NY\",\r\n \"postal_code\": \"10282\",\r\n \"country_code\": \"US\",\r\n \"address_residential_indicator\": \"unknown\"\r\n },\r\n \"confirmation\": \"none\",\r\n \"customs\": null,\r\n \"advanced_options\": {\r\n \"bill_to_account\": null,\r\n \"bill_to_country_code\": null,\r\n \"bill_to_party\": null,\r\n \"bill_to_postal_code\": null,\r\n \"contains_alcohol\": false,\r\n \"delivered_duty_paid\": false,\r\n \"non_machinable\": false,\r\n \"saturday_delivery\": false,\r\n \"freight_class\": null,\r\n \"custom_field1\": null,\r\n \"custom_field2\": null,\r\n \"custom_field3\": null\r\n },\r\n \"insurance_provider\": \"none\",\r\n \"tags\": [],\r\n \"packages\": [\r\n {\r\n \"package_code\": \"package\",\r\n \"weight\": {\r\n \"value\": 1.00,\r\n \"unit\": \"ounce\"\r\n },\r\n \"dimensions\": {\r\n \"unit\": \"inch\",\r\n \"length\": 0.0,\r\n \"width\": 0.0,\r\n \"height\": 0.0\r\n },\r\n \"insured_value\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"label_messages\": {\r\n \"reference1\": null,\r\n \"reference2\": null,\r\n \"reference3\": null\r\n }\r\n }\r\n ],\r\n \"total_weight\": {\r\n \"value\": 1.00,\r\n \"unit\": \"ounce\"\r\n }\r\n}" ]
Thursday, August 23, 2018 6:36 PM -
User475983607 posted
You are not following the example code at all... not sure what else I can do for you.
Can you explain why you keep using this syntax...
Dim jsonArrRateResponses As Newtonsoft.Json.Linq.JArray = New Linq.JArray(strResponseFromServerRateResponse)
Rather than just grabbing the data using standard .NET syntax?
Thursday, August 23, 2018 6:38 PM -
User-125499312 posted
<g class="gr_ gr_15 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="15" data-gr-id="15">i</g> am getting the <g class="gr_ gr_24 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling" id="24" data-gr-id="24">json</g> from a <g class="gr_ gr_33 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="33" data-gr-id="33">webrequest</g> to <g class="gr_ gr_49 gr-alert gr_spell gr_inline_cards gr_disable_anim_appear ContextualSpelling ins-del multiReplace" id="49" data-gr-id="49">shipengine</g>, and it is not in a file.
other than that <g class="gr_ gr_124 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="124" data-gr-id="124">i</g> am following your code
Dim strJSON As String = GetShipEngineRateJSON()
Dim wrRequest As WebRequest = HttpWebRequest.Create("https://api.shipengine.com/v1/rates")
wrRequest.Method = "POST"
wrRequest.ContentType = "application/json"
wrRequest.Headers.Add("api-key", strShipEngineAPIKey)Dim datastreamin() As Byte = Encoding.UTF8.GetBytes(strJSON)
wrRequest.ContentLength = datastreamin.LengthDim newstream As Stream = wrRequest.GetRequestStream
newstream.Write(datastreamin, 0, datastreamin.Length)
newstream.Close()Dim wrResponse As WebResponse = wrRequest.GetResponse
Dim srReader As StreamReader = New StreamReader(wrResponse.GetResponseStream)
Dim strResponseFromServerRateResponse As String = srReader.ReadToEndDim jsonResult = (Newtonsoft.Json.JsonConvert.DeserializeObject(Of Rootobject)(strResponseFromServerRateResponse))
Dim root As Rootobject = (Newtonsoft.Json.JsonConvert.DeserializeObject(Of Rootobject)(strResponseFromServerRateResponse))
Dim ratResponse As Rate_Response = jsonResult.rate_response
Dim jsonArrRateResponses As Newtonsoft.Json.Linq.JArray = New Linq.JArray(strResponseFromServerRateResponse)For Each objRateResponse As Object In jsonArrRateResponses
next
what am i doing wrong?
Thursday, August 23, 2018 6:44 PM -
User475983607 posted
I have no idea what you are trying to do... A few posts ago you where looking for the shipping_id and I provided the code to get that value. Now you're doing something else...
Explain the problem you are trying to solve.
Why do you keep writing this line of code when you already have the object?
Dim jsonArrRateResponses As Newtonsoft.Json.Linq.JArray = New Linq.JArray(strResponseFromServerRateResponse)
Thursday, August 23, 2018 7:00 PM -
User1120430333 posted
Maybe, you should just use Webclient(), because it's a lot more simpler to use.
Imports System.Net Imports System.Net.Http Imports System.Net.Http.Headers Imports Entities Imports Newtonsoft.Json Imports Newtonsoft.Json.Linq Namespace WebApi Public Class WebApi Implements IWebApi #Region "Project" public Function GetProjsByUserIdApi(userid As String) as List(of DtoProject) Implements IWebApi.GetProjsByUserIdApi dim dtoprojects = new List(Of DtoProject) dim url = "http://localhost/WebApiVB/api/project/GetProjectsByUserId?userid=" & userid Using webclient As New WebClient dim json = webclient.DownloadString(url) Dim projects = JsonConvert.DeserializeObject(of List(Of DtoProject))(json) dtoprojects = projects End Using Return dtoprojects End Function public Function GetProjByIdApi(id As int32) as DtoProject Implements IWebApi.GetProjByIdApi dim dto as DtoProject dim url = "http://localhost/WebApiVB/api/project/GetProjectById?id=" & id Using webclient As New WebClient dim json = webclient.DownloadString(url) Dim project = JsonConvert.DeserializeObject(of DtoProject)(json) dto = project End Using Return dto End Function public sub CreateProjectApi(dto As DtoProject) Implements IWebApi.CreateProjectApi Dim reqString As byte() Using webclient As New WebClient dim url as string = "http://localhost/WebApiVB/api/project/CreateProject" webClient.Headers("content-type") = "application/json" reqString = Encoding.Default.GetBytes(JsonConvert.SerializeObject(dto, Formatting.Indented)) webClient.UploadData(url, "post", reqString) End Using End sub public sub UpdateProjectApi(dto As DtoProject) Implements IWebApi.UpdateProjectApi Dim reqString As byte() Using webclient As New WebClient dim url as string = "http://localhost/WebApiVB/api/project/UpdateProject" webClient.Headers("content-type") = "application/json" reqString = Encoding.Default.GetBytes(JsonConvert.SerializeObject(dto, Formatting.Indented)) webClient.UploadData(url, "post", reqString) End Using End sub public sub DeleteProjectApi(dto As DtoId) Implements IWebApi.DeleteProjectApi Dim reqString As byte() Using webclient As New WebClient dim url as string = "http://localhost/WebApiVB/api/project/DeleteProject" webClient.Headers("content-type") = "application/json" reqString = Encoding.Default.GetBytes(JsonConvert.SerializeObject(dto, Formatting.Indented)) webClient.UploadData(url, "post", reqString) End Using End sub #End Region #Region "Task" public function GetTasksByProjIdApi(id as int32) as List(Of DtoTask) Implements IWebApi.GetTasksByProjIdApi Dim dtotasks = new List(Of DtoTask) dim url = "http://localhost/WebApiVB/api/task/GetTasksByProjectId?id=" & id Using webclient As New WebClient dim json = webclient.DownloadString(url) Dim tasks = JsonConvert.DeserializeObject(of List(Of DtoTask))(json) dtotasks = tasks End Using Return dtotasks End function public Function GetTaskByIdApi(id As int32) As DtoTask Implements IWebApi.GetTaskByIdApi dim dto as DtoTask dim url = "http://localhost/WebApiVB/api/task/GetTaskById?id=" & id Using webclient As New WebClient dim json = webclient.DownloadString(url) Dim task = JsonConvert.DeserializeObject(of DtoTask)(json) dto = task End Using return dto End Function public sub CreateTaskApi(dto As DtoTask) Implements IWebApi.CreateTaskApi Dim reqString As byte() Using webclient As New WebClient dim url as string = "http://localhost/WebApiVB/api/task/CreateTask" webClient.Headers("content-type") = "application/json" reqString = Encoding.Default.GetBytes(JsonConvert.SerializeObject(dto, Formatting.Indented)) webClient.UploadData(url, "post", reqString) End Using End sub public sub UpdateTaskApi(dto As DtoTask) Implements IWebApi.UpdateTaskApi Dim reqString As byte() Using webclient As New WebClient dim url as string = "http://localhost/WebApiVB/api/task/UpdateTask" webClient.Headers("content-type") = "application/json" reqString = Encoding.Default.GetBytes(JsonConvert.SerializeObject(dto, Formatting.Indented)) webClient.UploadData(url, "post", reqString) End Using End sub public sub DeleteTaskApi(dto As DtoId) Implements IWebApi.DeleteTaskApi Dim reqString As byte() Using webclient As New WebClient dim url as string = "http://localhost/WebApiVB/api/task/DeleteTask" webClient.Headers("content-type") = "application/json" reqString = Encoding.Default.GetBytes(JsonConvert.SerializeObject(dto, Formatting.Indented)) webClient.UploadData(url, "post", reqString) End Using End sub #End Region #Region "Cache" public Function GetCacheApi() As DtoCache Implements IWebApi.GetCacheApi dim dtocache = new DtoCache() dim url = "http://localhost/WebApiVB/api/cache/GetCache" Using webclient As New WebClient dim json = webclient.DownloadString(url) Dim deserialized = JsonConvert.DeserializeObject(of DtoCacheRoot)(json) dtocache.ProjectTypes = deserialized.DtoCache.ProjectTypes dtocache.Durations = deserialized.DtoCache.Durations dtocache.Statuses = deserialized.DtoCache.Statuses dtocache.Resources = deserialized.DtoCache.Resources End Using return dtocache End Function #End Region End Class End Namespace
Thursday, August 23, 2018 9:09 PM -
User-125499312 posted
hi <g class="gr_ gr_5 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="5" data-gr-id="5">mgebhard</g>,
<g class="gr_ gr_33 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="33" data-gr-id="33">i</g> appreciate your help and your patience. I don't have much experience with JSON.
<g class="gr_ gr_125 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="125" data-gr-id="125">i</g> am working with the <g class="gr_ gr_143 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="143" data-gr-id="143">shipengine</g> API and I would like extract child values to populate a drop-down list with rates for a particular purchase.
the rate_respone object contains multiple rate objects and individual child values as well
<g class="gr_ gr_665 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="665" data-gr-id="665">i</g> want to thank you again for your help and your patience.
Thursday, August 23, 2018 10:08 PM -
User475983607 posted
the rate_respone object contains multiple rate objects and individual child values as wellI'm not familiar with shipengine API but I'm sure you can visit there support site for assistance. More importantly, you have the object so all you have to do is use standard "dot" notation to fetch property values. I have no idea what properties you want. You need to figure that out...
Dim ResponseFromServer As String = System.IO.File.ReadAllText("json1.json") Dim root As Rootobject = (Newtonsoft.Json.JsonConvert.DeserializeObject(Of Rootobject)(ResponseFromServer)) Dim rates As List(Of Rate) = root.rate_response.rates For Each r As Rate In rates Console.WriteLine("{0} - {1}", r.shipping_amount.amount, r.shipping_amount.currency) Next
Thursday, August 23, 2018 10:34 PM -
User-125499312 posted
hi
Dim rates As List(Of Rate) = root.rate_response.rates
is generating this error:
Object reference not set to an instance of an object.
thx
Friday, August 24, 2018 2:44 PM -
User475983607 posted
Dim rates As List(Of Rate) = root.rate_response.rates
is generating this error:
Object reference not set to an instance of an object.
It's work perfectly for me give the JSON in your post. It's not possible to determine the source of your error given the one line of code but I suspect there is an issue with fetching the data. Run your code through the debugger.
Friday, August 24, 2018 3:10 PM -
User-125499312 posted
here is the JSON
********
strResponseFromServerRateResponse:
{ "rate_response": { "rates": [ { "rate_id": "se-19637449", "rate_type": "shipment", "carrier_id": "se-187971", "shipping_amount": { "currency": "usd", "amount": 10.24 }, "insurance_amount": { "currency": "usd", "amount": 0.00 }, "confirmation_amount": { "currency": "usd", "amount": 0.00 }, "other_amount": { "currency": "usd", "amount": 0.05 }, "zone": null, "package_type": null, "delivery_days": 6, "guaranteed_service": false, "estimated_delivery_date": "2018-08-30T23:00:00Z", "carrier_delivery_days": "Thursday 8/30 by 11:00 PM", "ship_date": "2018-08-24T00:00:00Z", "negotiated_rate": false, "service_type": "UPS® Ground", "service_code": "ups_ground", "trackable": true, "carrier_code": "ups", "carrier_nickname": "yechiel zidell", "carrier_friendly_name": "UPS", "validation_status": "valid", "warning_messages": [], "error_messages": [] }, { "rate_id": "se-19637450", "rate_type": "shipment", "carrier_id": "se-187971", "shipping_amount": { "currency": "usd", "amount": 23.75 }, "insurance_amount": { "currency": "usd", "amount": 0.00 }, "confirmation_amount": { "currency": "usd", "amount": 0.00 }, "other_amount": { "currency": "usd", "amount": 0.20 }, "zone": null, "package_type": null, "delivery_days": 3, "guaranteed_service": true, "estimated_delivery_date": "2018-08-29T23:00:00Z", "carrier_delivery_days": "Wednesday 8/29 by 11:00 PM", "ship_date": "2018-08-24T00:00:00Z", "negotiated_rate": false, "service_type": "UPS 3 Day Select®", "service_code": "ups_3_day_select", "trackable": true, "carrier_code": "ups", "carrier_nickname": "yechiel zidell", "carrier_friendly_name": "UPS", "validation_status": "valid", "warning_messages": [], "error_messages": [] }, { "rate_id": "se-19637451", "rate_type": "shipment", "carrier_id": "se-187971", "shipping_amount": { "currency": "usd", "amount": 35.31 }, "insurance_amount": { "currency": "usd", "amount": 0.00 }, "confirmation_amount": { "currency": "usd", "amount": 0.00 }, "other_amount": { "currency": "usd", "amount": 0.20 }, "zone": null, "package_type": null, "delivery_days": 2, "guaranteed_service": true, "estimated_delivery_date": "2018-08-28T10:30:00Z", "carrier_delivery_days": "Tuesday 8/28 by 10:30 AM", "ship_date": "2018-08-24T00:00:00Z", "negotiated_rate": false, "service_type": "UPS 2nd Day Air AM®", "service_code": "ups_2nd_day_air_am", "trackable": true, "carrier_code": "ups", "carrier_nickname": "yechiel zidell", "carrier_friendly_name": "UPS", "validation_status": "valid", "warning_messages": [], "error_messages": [] }, { "rate_id": "se-19637452", "rate_type": "shipment", "carrier_id": "se-187971", "shipping_amount": { "currency": "usd", "amount": 30.55 }, "insurance_amount": { "currency": "usd", "amount": 0.00 }, "confirmation_amount": { "currency": "usd", "amount": 0.00 }, "other_amount": { "currency": "usd", "amount": 0.20 }, "zone": null, "package_type": null, "delivery_days": 2, "guaranteed_service": true, "estimated_delivery_date": "2018-08-28T23:00:00Z", "carrier_delivery_days": "Tuesday 8/28 by 11:00 PM", "ship_date": "2018-08-24T00:00:00Z", "negotiated_rate": false, "service_type": "UPS 2nd Day Air®", "service_code": "ups_2nd_day_air", "trackable": true, "carrier_code": "ups", "carrier_nickname": "yechiel zidell", "carrier_friendly_name": "UPS", "validation_status": "valid", "warning_messages": [], "error_messages": [] }, { "rate_id": "se-19637453", "rate_type": "shipment", "carrier_id": "se-187971", "shipping_amount": { "currency": "usd", "amount": 69.87 }, "insurance_amount": { "currency": "usd", "amount": 0.00 }, "confirmation_amount": { "currency": "usd", "amount": 0.00 }, "other_amount": { "currency": "usd", "amount": 0.20 }, "zone": null, "package_type": null, "delivery_days": 1, "guaranteed_service": true, "estimated_delivery_date": "2018-08-27T15:00:00Z", "carrier_delivery_days": "Monday 8/27 by 03:00 PM", "ship_date": "2018-08-24T00:00:00Z", "negotiated_rate": false, "service_type": "UPS Next Day Air Saver®", "service_code": "ups_next_day_air_saver", "trackable": true, "carrier_code": "ups", "carrier_nickname": "yechiel zidell", "carrier_friendly_name": "UPS", "validation_status": "valid", "warning_messages": [], "error_messages": [] }, { "rate_id": "se-19637454", "rate_type": "shipment", "carrier_id": "se-187971", "shipping_amount": { "currency": "usd", "amount": 109.43 }, "insurance_amount": { "currency": "usd", "amount": 0.00 }, "confirmation_amount": { "currency": "usd", "amount": 0.00 }, "other_amount": { "currency": "usd", "amount": 0.20 }, "zone": null, "package_type": null, "delivery_days": 1, "guaranteed_service": true, "estimated_delivery_date": "2018-08-25T09:30:00Z", "carrier_delivery_days": "Tomorrow by 09:30 AM", "ship_date": "2018-08-24T00:00:00Z", "negotiated_rate": false, "service_type": "UPS Next Day Air® Early", "service_code": "ups_next_day_air_early_am", "trackable": true, "carrier_code": "ups", "carrier_nickname": "yechiel zidell", "carrier_friendly_name": "UPS", "validation_status": "valid", "warning_messages": [], "error_messages": [] }, { "rate_id": "se-19637455", "rate_type": "shipment", "carrier_id": "se-187971", "shipping_amount": { "currency": "usd", "amount": 77.03 }, "insurance_amount": { "currency": "usd", "amount": 0.00 }, "confirmation_amount": { "currency": "usd", "amount": 0.00 }, "other_amount": { "currency": "usd", "amount": 0.20 }, "zone": null, "package_type": null, "delivery_days": 1, "guaranteed_service": true, "estimated_delivery_date": "2018-08-25T12:00:00Z", "carrier_delivery_days": "Tomorrow by 12:00 PM", "ship_date": "2018-08-24T00:00:00Z", "negotiated_rate": false, "service_type": "UPS Next Day Air®", "service_code": "ups_next_day_air", "trackable": true, "carrier_code": "ups", "carrier_nickname": "yechiel zidell", "carrier_friendly_name": "UPS", "validation_status": "valid", "warning_messages": [], "error_messages": [] } ], "invalid_rates": [], "rate_request_id": "se-1153426", "shipment_id": "se-247642839", "created_at": "2018-08-24T20:31:48.297Z", "status": "completed", "errors": [] }, "shipment_id": "se-247642839", "carrier_id": null, "service_code": null, "external_shipment_id": null, "ship_date": "2018-08-24T00:00:00Z", "created_at": "2018-08-24T20:31:47.27Z", "modified_at": "2018-08-24T20:31:47.27Z", "shipment_status": "pending", "ship_to": { "name": "Mickey and Minnie Mouse", "phone": "714-781-4565", "company_name": "The Walt Disney Company", "address_line1": "500 South Buena Vista Street", "address_line2": null, "address_line3": null, "city_locality": "Burbank", "state_province": "CA", "postal_code": "91521", "country_code": "US", "address_residential_indicator": "unknown" }, "ship_from": { "name": "Dade Murphy", "phone": "512-485-4282", "company_name": "Zero Cool", "address_line1": "345 Chambers Street", "address_line2": "Suite 100", "address_line3": null, "city_locality": "New York City", "state_province": "NY", "postal_code": "10282", "country_code": "US", "address_residential_indicator": "unknown" }, "warehouse_id": null, "return_to": { "name": "Dade Murphy", "phone": "512-485-4282", "company_name": "Zero Cool", "address_line1": "345 Chambers Street", "address_line2": "Suite 100", "address_line3": null, "city_locality": "New York City", "state_province": "NY", "postal_code": "10282", "country_code": "US", "address_residential_indicator": "unknown" }, "confirmation": "none", "customs": null, "advanced_options": { "bill_to_account": null, "bill_to_country_code": null, "bill_to_party": null, "bill_to_postal_code": null, "contains_alcohol": false, "delivered_duty_paid": false, "non_machinable": false, "saturday_delivery": false, "freight_class": null, "custom_field1": null, "custom_field2": null, "custom_field3": null }, "insurance_provider": "none", "tags": [], "packages": [ { "package_code": "package", "weight": { "value": 1.00, "unit": "ounce" }, "dimensions": { "unit": "inch", "length": 0.0, "width": 0.0, "height": 0.0 }, "insured_value": { "currency": "usd", "amount": 0.00 }, "label_messages": { "reference1": null, "reference2": null, "reference3": null } } ], "total_weight": { "value": 1.00, "unit": "ounce" } }
********
********
jsonArrRateResponses.ToString:
[ "{\r\n \"rate_response\": {\r\n \"rates\": [\r\n {\r\n \"rate_id\": \"se-19637449\",\r\n \"rate_type\": \"shipment\",\r\n \"carrier_id\": \"se-187971\",\r\n \"shipping_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 10.24\r\n },\r\n \"insurance_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"confirmation_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"other_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.05\r\n },\r\n \"zone\": null,\r\n \"package_type\": null,\r\n \"delivery_days\": 6,\r\n \"guaranteed_service\": false,\r\n \"estimated_delivery_date\": \"2018-08-30T23:00:00Z\",\r\n \"carrier_delivery_days\": \"Thursday 8/30 by 11:00 PM\",\r\n \"ship_date\": \"2018-08-24T00:00:00Z\",\r\n \"negotiated_rate\": false,\r\n \"service_type\": \"UPS® Ground\",\r\n \"service_code\": \"ups_ground\",\r\n \"trackable\": true,\r\n \"carrier_code\": \"ups\",\r\n \"carrier_nickname\": \"yechiel zidell\",\r\n \"carrier_friendly_name\": \"UPS\",\r\n \"validation_status\": \"valid\",\r\n \"warning_messages\": [],\r\n \"error_messages\": []\r\n },\r\n {\r\n \"rate_id\": \"se-19637450\",\r\n \"rate_type\": \"shipment\",\r\n \"carrier_id\": \"se-187971\",\r\n \"shipping_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 23.75\r\n },\r\n \"insurance_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"confirmation_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"other_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.20\r\n },\r\n \"zone\": null,\r\n \"package_type\": null,\r\n \"delivery_days\": 3,\r\n \"guaranteed_service\": true,\r\n \"estimated_delivery_date\": \"2018-08-29T23:00:00Z\",\r\n \"carrier_delivery_days\": \"Wednesday 8/29 by 11:00 PM\",\r\n \"ship_date\": \"2018-08-24T00:00:00Z\",\r\n \"negotiated_rate\": false,\r\n \"service_type\": \"UPS 3 Day Select®\",\r\n \"service_code\": \"ups_3_day_select\",\r\n \"trackable\": true,\r\n \"carrier_code\": \"ups\",\r\n \"carrier_nickname\": \"yechiel zidell\",\r\n \"carrier_friendly_name\": \"UPS\",\r\n \"validation_status\": \"valid\",\r\n \"warning_messages\": [],\r\n \"error_messages\": []\r\n },\r\n {\r\n \"rate_id\": \"se-19637451\",\r\n \"rate_type\": \"shipment\",\r\n \"carrier_id\": \"se-187971\",\r\n \"shipping_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 35.31\r\n },\r\n \"insurance_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"confirmation_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"other_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.20\r\n },\r\n \"zone\": null,\r\n \"package_type\": null,\r\n \"delivery_days\": 2,\r\n \"guaranteed_service\": true,\r\n \"estimated_delivery_date\": \"2018-08-28T10:30:00Z\",\r\n \"carrier_delivery_days\": \"Tuesday 8/28 by 10:30 AM\",\r\n \"ship_date\": \"2018-08-24T00:00:00Z\",\r\n \"negotiated_rate\": false,\r\n \"service_type\": \"UPS 2nd Day Air AM®\",\r\n \"service_code\": \"ups_2nd_day_air_am\",\r\n \"trackable\": true,\r\n \"carrier_code\": \"ups\",\r\n \"carrier_nickname\": \"yechiel zidell\",\r\n \"carrier_friendly_name\": \"UPS\",\r\n \"validation_status\": \"valid\",\r\n \"warning_messages\": [],\r\n \"error_messages\": []\r\n },\r\n {\r\n \"rate_id\": \"se-19637452\",\r\n \"rate_type\": \"shipment\",\r\n \"carrier_id\": \"se-187971\",\r\n \"shipping_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 30.55\r\n },\r\n \"insurance_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"confirmation_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"other_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.20\r\n },\r\n \"zone\": null,\r\n \"package_type\": null,\r\n \"delivery_days\": 2,\r\n \"guaranteed_service\": true,\r\n \"estimated_delivery_date\": \"2018-08-28T23:00:00Z\",\r\n \"carrier_delivery_days\": \"Tuesday 8/28 by 11:00 PM\",\r\n \"ship_date\": \"2018-08-24T00:00:00Z\",\r\n \"negotiated_rate\": false,\r\n \"service_type\": \"UPS 2nd Day Air®\",\r\n \"service_code\": \"ups_2nd_day_air\",\r\n \"trackable\": true,\r\n \"carrier_code\": \"ups\",\r\n \"carrier_nickname\": \"yechiel zidell\",\r\n \"carrier_friendly_name\": \"UPS\",\r\n \"validation_status\": \"valid\",\r\n \"warning_messages\": [],\r\n \"error_messages\": []\r\n },\r\n {\r\n \"rate_id\": \"se-19637453\",\r\n \"rate_type\": \"shipment\",\r\n \"carrier_id\": \"se-187971\",\r\n \"shipping_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 69.87\r\n },\r\n \"insurance_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"confirmation_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"other_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.20\r\n },\r\n \"zone\": null,\r\n \"package_type\": null,\r\n \"delivery_days\": 1,\r\n \"guaranteed_service\": true,\r\n \"estimated_delivery_date\": \"2018-08-27T15:00:00Z\",\r\n \"carrier_delivery_days\": \"Monday 8/27 by 03:00 PM\",\r\n \"ship_date\": \"2018-08-24T00:00:00Z\",\r\n \"negotiated_rate\": false,\r\n \"service_type\": \"UPS Next Day Air Saver®\",\r\n \"service_code\": \"ups_next_day_air_saver\",\r\n \"trackable\": true,\r\n \"carrier_code\": \"ups\",\r\n \"carrier_nickname\": \"yechiel zidell\",\r\n \"carrier_friendly_name\": \"UPS\",\r\n \"validation_status\": \"valid\",\r\n \"warning_messages\": [],\r\n \"error_messages\": []\r\n },\r\n {\r\n \"rate_id\": \"se-19637454\",\r\n \"rate_type\": \"shipment\",\r\n \"carrier_id\": \"se-187971\",\r\n \"shipping_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 109.43\r\n },\r\n \"insurance_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"confirmation_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"other_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.20\r\n },\r\n \"zone\": null,\r\n \"package_type\": null,\r\n \"delivery_days\": 1,\r\n \"guaranteed_service\": true,\r\n \"estimated_delivery_date\": \"2018-08-25T09:30:00Z\",\r\n \"carrier_delivery_days\": \"Tomorrow by 09:30 AM\",\r\n \"ship_date\": \"2018-08-24T00:00:00Z\",\r\n \"negotiated_rate\": false,\r\n \"service_type\": \"UPS Next Day Air® Early\",\r\n \"service_code\": \"ups_next_day_air_early_am\",\r\n \"trackable\": true,\r\n \"carrier_code\": \"ups\",\r\n \"carrier_nickname\": \"yechiel zidell\",\r\n \"carrier_friendly_name\": \"UPS\",\r\n \"validation_status\": \"valid\",\r\n \"warning_messages\": [],\r\n \"error_messages\": []\r\n },\r\n {\r\n \"rate_id\": \"se-19637455\",\r\n \"rate_type\": \"shipment\",\r\n \"carrier_id\": \"se-187971\",\r\n \"shipping_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 77.03\r\n },\r\n \"insurance_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"confirmation_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"other_amount\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.20\r\n },\r\n \"zone\": null,\r\n \"package_type\": null,\r\n \"delivery_days\": 1,\r\n \"guaranteed_service\": true,\r\n \"estimated_delivery_date\": \"2018-08-25T12:00:00Z\",\r\n \"carrier_delivery_days\": \"Tomorrow by 12:00 PM\",\r\n \"ship_date\": \"2018-08-24T00:00:00Z\",\r\n \"negotiated_rate\": false,\r\n \"service_type\": \"UPS Next Day Air®\",\r\n \"service_code\": \"ups_next_day_air\",\r\n \"trackable\": true,\r\n \"carrier_code\": \"ups\",\r\n \"carrier_nickname\": \"yechiel zidell\",\r\n \"carrier_friendly_name\": \"UPS\",\r\n \"validation_status\": \"valid\",\r\n \"warning_messages\": [],\r\n \"error_messages\": []\r\n }\r\n ],\r\n \"invalid_rates\": [],\r\n \"rate_request_id\": \"se-1153426\",\r\n \"shipment_id\": \"se-247642839\",\r\n \"created_at\": \"2018-08-24T20:31:48.297Z\",\r\n \"status\": \"completed\",\r\n \"errors\": []\r\n },\r\n \"shipment_id\": \"se-247642839\",\r\n \"carrier_id\": null,\r\n \"service_code\": null,\r\n \"external_shipment_id\": null,\r\n \"ship_date\": \"2018-08-24T00:00:00Z\",\r\n \"created_at\": \"2018-08-24T20:31:47.27Z\",\r\n \"modified_at\": \"2018-08-24T20:31:47.27Z\",\r\n \"shipment_status\": \"pending\",\r\n \"ship_to\": {\r\n \"name\": \"Mickey and Minnie Mouse\",\r\n \"phone\": \"714-781-4565\",\r\n \"company_name\": \"The Walt Disney Company\",\r\n \"address_line1\": \"500 South Buena Vista Street\",\r\n \"address_line2\": null,\r\n \"address_line3\": null,\r\n \"city_locality\": \"Burbank\",\r\n \"state_province\": \"CA\",\r\n \"postal_code\": \"91521\",\r\n \"country_code\": \"US\",\r\n \"address_residential_indicator\": \"unknown\"\r\n },\r\n \"ship_from\": {\r\n \"name\": \"Dade Murphy\",\r\n \"phone\": \"512-485-4282\",\r\n \"company_name\": \"Zero Cool\",\r\n \"address_line1\": \"345 Chambers Street\",\r\n \"address_line2\": \"Suite 100\",\r\n \"address_line3\": null,\r\n \"city_locality\": \"New York City\",\r\n \"state_province\": \"NY\",\r\n \"postal_code\": \"10282\",\r\n \"country_code\": \"US\",\r\n \"address_residential_indicator\": \"unknown\"\r\n },\r\n \"warehouse_id\": null,\r\n \"return_to\": {\r\n \"name\": \"Dade Murphy\",\r\n \"phone\": \"512-485-4282\",\r\n \"company_name\": \"Zero Cool\",\r\n \"address_line1\": \"345 Chambers Street\",\r\n \"address_line2\": \"Suite 100\",\r\n \"address_line3\": null,\r\n \"city_locality\": \"New York City\",\r\n \"state_province\": \"NY\",\r\n \"postal_code\": \"10282\",\r\n \"country_code\": \"US\",\r\n \"address_residential_indicator\": \"unknown\"\r\n },\r\n \"confirmation\": \"none\",\r\n \"customs\": null,\r\n \"advanced_options\": {\r\n \"bill_to_account\": null,\r\n \"bill_to_country_code\": null,\r\n \"bill_to_party\": null,\r\n \"bill_to_postal_code\": null,\r\n \"contains_alcohol\": false,\r\n \"delivered_duty_paid\": false,\r\n \"non_machinable\": false,\r\n \"saturday_delivery\": false,\r\n \"freight_class\": null,\r\n \"custom_field1\": null,\r\n \"custom_field2\": null,\r\n \"custom_field3\": null\r\n },\r\n \"insurance_provider\": \"none\",\r\n \"tags\": [],\r\n \"packages\": [\r\n {\r\n \"package_code\": \"package\",\r\n \"weight\": {\r\n \"value\": 1.00,\r\n \"unit\": \"ounce\"\r\n },\r\n \"dimensions\": {\r\n \"unit\": \"inch\",\r\n \"length\": 0.0,\r\n \"width\": 0.0,\r\n \"height\": 0.0\r\n },\r\n \"insured_value\": {\r\n \"currency\": \"usd\",\r\n \"amount\": 0.00\r\n },\r\n \"label_messages\": {\r\n \"reference1\": null,\r\n \"reference2\": null,\r\n \"reference3\": null\r\n }\r\n }\r\n ],\r\n \"total_weight\": {\r\n \"value\": 1.00,\r\n \"unit\": \"ounce\"\r\n }\r\n}" ]
********Friday, August 24, 2018 8:34 PM -
User475983607 posted
For some reason only known to you, you simply will not follow the basic instructions. You keep using jArray and not an .NET type as shown several time now.
There's nothing I can do for you.
Friday, August 24, 2018 8:39 PM