0

new to this site so please bear with me.

this is the code i use to get json data:

response = HttpReq.responsetext

this is the response i get:

{"status":200,"message":"Order(s) created successfully","data":[{"index":0,"referenceId":"307103f84dc94ee188d1111db0cdad86","orderNumber":"7081035854","shipmentOrderTypeCd":"DELIVER","orderState":"FORWARD"}],"hasError":false}

how do i get the referenceId in the following format so that i can use the value to update my database?

referenceId = 307103f84dc94ee188d1111db0cdad86

all help appreciated. Thanks

1

1 Answer 1

0

This is a common thing where I work, as we deal with JSON from API requests.

By far the easiest IMO is to use JSON.Net. Here's how to get in NuGet: https://www.nuget.org/packages/newtonsoft.json/

Super easy example: https://www.newtonsoft.com/json/help/html/DeserializeObject.htm

So in your case you'd have a class similar to your response (can do a paste special in VS to make a class automatically from a response) And then Newtonsoft does the rest like so:

Dim orderResponse As Order = JsonConvert.DeserializeObject(Of Order)(HttpReq.responsetext)
Console.WriteLine(orderResponse.Data(0).referenceId); //maybe depending on your class you deserialize into
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.