How do you parse this JSON data?How do I format a Microsoft JSON date?Can comments be used in JSON?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How to parse JSON in JavaWhy does Google prepend while(1); to their JSON responses?Why can't Python parse this JSON data?How can I pretty-print JSON using JavaScript?Parse JSON in JavaScript?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?

MAXDOP Settings for SQL Server 2014

Did US corporations pay demonstrators in the German demonstrations against article 13?

Freedom of speech and where it applies

How will losing mobility of one hand affect my career as a programmer?

How to color a curve

What linear sensor for a keyboard?

Confusion on Parallelogram

API Access HTML/Javascript

Drawing ramified coverings with tikz

On a tidally locked planet, would time be quantized?

Global amount of publications over time

Will adding a BY-SA image to a blog post make the entire post BY-SA?

How can "mimic phobia" be cured or prevented?

Why is Arduino resetting while driving motors?

If a character with the Alert feat rolls a crit fail on their Perception check, are they surprised?

When quoting, must I also copy hyphens used to divide words that continue on the next line?

How do I implement a file system driver driver in Linux?

Is camera lens focus an exact point or a range?

Find last 3 digits of this monster number

Could solar power be utilized and substitute coal in the 19th Century

Varistor? Purpose and principle

How do I extrude a face to a single vertex

Reply 'no position' while the job posting is still there

Have I saved too much for retirement so far?



How do you parse this JSON data?


How do I format a Microsoft JSON date?Can comments be used in JSON?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How to parse JSON in JavaWhy does Google prepend while(1); to their JSON responses?Why can't Python parse this JSON data?How can I pretty-print JSON using JavaScript?Parse JSON in JavaScript?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?













-1















I have this JSON data that I would like to parse but I'm not sure how to go about it.

Here's the JSON:




"input":
"lat":32.761125,
"lon":-96.791339
,
"results":[

"block_fips":"481130204001105",
"bbox":[
-96.79587,
32.753273,
-96.787714,
32.76218
],
"county_fips":"48113",
"county_name":"Dallas",
"state_fips":"48",
"state_code":"TX",
"state_name":"Texas",
"block_pop_2015":2,
"amt":"AMT004",
"bea":"BEA127",
"bta":"BTA101",
"cma":"CMA009",
"eag":"EAG005",
"ivm":"IVM009",
"mea":"MEA032",
"mta":"MTA007",
"pea":"PEA008",
"rea":"REA005",
"rpc":"RPC004",
"vpc":"VPC004"

]



I used the Visual Studio tool, Edit -> Paste Special -> Paste as JSON classes, to convert this JSON in classes and it gave me this class structure:



Public Class Rootobject
Public Property input As Input
Public Property results() As Result
End Class

Public Class Input
Public Property lat As Single
Public Property lon As Single
End Class

Public Class Result
Public Property block_fips As String
Public Property bbox() As Single
Public Property county_fips As String
Public Property county_name As String
Public Property state_fips As String
Public Property state_code As String
Public Property state_name As String
Public Property block_pop_2015 As Integer
Public Property amt As String
Public Property bea As String
Public Property bta As String
Public Property cma As String
Public Property eag As String
Public Property ivm As String
Public Property mea As String
Public Property mta As String
Public Property pea As String
Public Property rea As String
Public Property rpc As String
Public Property vpc As String
End Class


So then what I did to try and parse the data is:



Dim MyJSON As String = JsonAbove
Dim jss As New JavaScriptSerializer()
Dim dict = jss.Deserialize(Of Result)(rawresp)
MsgBox(dict.state_name)


All I get is a blank MessageBox with no results.

Am I doing something wrong?










share|improve this question



















  • 1





    Try Dim dict = jss.Deserialize(Of Rootobject)(rawresp) instead Of Result

    – Akshay Gaonkar
    Mar 8 at 6:52











  • Would I then get the result with something like dict.results.state_name ? Because its saying that the result is not supported for deserialization of an array

    – The Newbie
    Mar 8 at 6:54






  • 1





    dict.results[0].state_name

    – Akshay Gaonkar
    Mar 8 at 6:59






  • 1





    Or Dim state As String = jss.Deserialize(Of Rootobject)(rawresp).results(0).state_name

    – Jimi
    Mar 8 at 7:05












  • Hi @Jimi - Trying your way produces the following error 'Public Property results As Result' has no parameters and its return type cannot be indexed

    – The Newbie
    Mar 8 at 7:08















-1















I have this JSON data that I would like to parse but I'm not sure how to go about it.

Here's the JSON:




"input":
"lat":32.761125,
"lon":-96.791339
,
"results":[

"block_fips":"481130204001105",
"bbox":[
-96.79587,
32.753273,
-96.787714,
32.76218
],
"county_fips":"48113",
"county_name":"Dallas",
"state_fips":"48",
"state_code":"TX",
"state_name":"Texas",
"block_pop_2015":2,
"amt":"AMT004",
"bea":"BEA127",
"bta":"BTA101",
"cma":"CMA009",
"eag":"EAG005",
"ivm":"IVM009",
"mea":"MEA032",
"mta":"MTA007",
"pea":"PEA008",
"rea":"REA005",
"rpc":"RPC004",
"vpc":"VPC004"

]



I used the Visual Studio tool, Edit -> Paste Special -> Paste as JSON classes, to convert this JSON in classes and it gave me this class structure:



Public Class Rootobject
Public Property input As Input
Public Property results() As Result
End Class

Public Class Input
Public Property lat As Single
Public Property lon As Single
End Class

Public Class Result
Public Property block_fips As String
Public Property bbox() As Single
Public Property county_fips As String
Public Property county_name As String
Public Property state_fips As String
Public Property state_code As String
Public Property state_name As String
Public Property block_pop_2015 As Integer
Public Property amt As String
Public Property bea As String
Public Property bta As String
Public Property cma As String
Public Property eag As String
Public Property ivm As String
Public Property mea As String
Public Property mta As String
Public Property pea As String
Public Property rea As String
Public Property rpc As String
Public Property vpc As String
End Class


So then what I did to try and parse the data is:



Dim MyJSON As String = JsonAbove
Dim jss As New JavaScriptSerializer()
Dim dict = jss.Deserialize(Of Result)(rawresp)
MsgBox(dict.state_name)


All I get is a blank MessageBox with no results.

Am I doing something wrong?










share|improve this question



















  • 1





    Try Dim dict = jss.Deserialize(Of Rootobject)(rawresp) instead Of Result

    – Akshay Gaonkar
    Mar 8 at 6:52











  • Would I then get the result with something like dict.results.state_name ? Because its saying that the result is not supported for deserialization of an array

    – The Newbie
    Mar 8 at 6:54






  • 1





    dict.results[0].state_name

    – Akshay Gaonkar
    Mar 8 at 6:59






  • 1





    Or Dim state As String = jss.Deserialize(Of Rootobject)(rawresp).results(0).state_name

    – Jimi
    Mar 8 at 7:05












  • Hi @Jimi - Trying your way produces the following error 'Public Property results As Result' has no parameters and its return type cannot be indexed

    – The Newbie
    Mar 8 at 7:08













-1












-1








-1








I have this JSON data that I would like to parse but I'm not sure how to go about it.

Here's the JSON:




"input":
"lat":32.761125,
"lon":-96.791339
,
"results":[

"block_fips":"481130204001105",
"bbox":[
-96.79587,
32.753273,
-96.787714,
32.76218
],
"county_fips":"48113",
"county_name":"Dallas",
"state_fips":"48",
"state_code":"TX",
"state_name":"Texas",
"block_pop_2015":2,
"amt":"AMT004",
"bea":"BEA127",
"bta":"BTA101",
"cma":"CMA009",
"eag":"EAG005",
"ivm":"IVM009",
"mea":"MEA032",
"mta":"MTA007",
"pea":"PEA008",
"rea":"REA005",
"rpc":"RPC004",
"vpc":"VPC004"

]



I used the Visual Studio tool, Edit -> Paste Special -> Paste as JSON classes, to convert this JSON in classes and it gave me this class structure:



Public Class Rootobject
Public Property input As Input
Public Property results() As Result
End Class

Public Class Input
Public Property lat As Single
Public Property lon As Single
End Class

Public Class Result
Public Property block_fips As String
Public Property bbox() As Single
Public Property county_fips As String
Public Property county_name As String
Public Property state_fips As String
Public Property state_code As String
Public Property state_name As String
Public Property block_pop_2015 As Integer
Public Property amt As String
Public Property bea As String
Public Property bta As String
Public Property cma As String
Public Property eag As String
Public Property ivm As String
Public Property mea As String
Public Property mta As String
Public Property pea As String
Public Property rea As String
Public Property rpc As String
Public Property vpc As String
End Class


So then what I did to try and parse the data is:



Dim MyJSON As String = JsonAbove
Dim jss As New JavaScriptSerializer()
Dim dict = jss.Deserialize(Of Result)(rawresp)
MsgBox(dict.state_name)


All I get is a blank MessageBox with no results.

Am I doing something wrong?










share|improve this question
















I have this JSON data that I would like to parse but I'm not sure how to go about it.

Here's the JSON:




"input":
"lat":32.761125,
"lon":-96.791339
,
"results":[

"block_fips":"481130204001105",
"bbox":[
-96.79587,
32.753273,
-96.787714,
32.76218
],
"county_fips":"48113",
"county_name":"Dallas",
"state_fips":"48",
"state_code":"TX",
"state_name":"Texas",
"block_pop_2015":2,
"amt":"AMT004",
"bea":"BEA127",
"bta":"BTA101",
"cma":"CMA009",
"eag":"EAG005",
"ivm":"IVM009",
"mea":"MEA032",
"mta":"MTA007",
"pea":"PEA008",
"rea":"REA005",
"rpc":"RPC004",
"vpc":"VPC004"

]



I used the Visual Studio tool, Edit -> Paste Special -> Paste as JSON classes, to convert this JSON in classes and it gave me this class structure:



Public Class Rootobject
Public Property input As Input
Public Property results() As Result
End Class

Public Class Input
Public Property lat As Single
Public Property lon As Single
End Class

Public Class Result
Public Property block_fips As String
Public Property bbox() As Single
Public Property county_fips As String
Public Property county_name As String
Public Property state_fips As String
Public Property state_code As String
Public Property state_name As String
Public Property block_pop_2015 As Integer
Public Property amt As String
Public Property bea As String
Public Property bta As String
Public Property cma As String
Public Property eag As String
Public Property ivm As String
Public Property mea As String
Public Property mta As String
Public Property pea As String
Public Property rea As String
Public Property rpc As String
Public Property vpc As String
End Class


So then what I did to try and parse the data is:



Dim MyJSON As String = JsonAbove
Dim jss As New JavaScriptSerializer()
Dim dict = jss.Deserialize(Of Result)(rawresp)
MsgBox(dict.state_name)


All I get is a blank MessageBox with no results.

Am I doing something wrong?







json vb.net






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 19:28









Jimi

9,50742035




9,50742035










asked Mar 8 at 6:49









The NewbieThe Newbie

9413




9413







  • 1





    Try Dim dict = jss.Deserialize(Of Rootobject)(rawresp) instead Of Result

    – Akshay Gaonkar
    Mar 8 at 6:52











  • Would I then get the result with something like dict.results.state_name ? Because its saying that the result is not supported for deserialization of an array

    – The Newbie
    Mar 8 at 6:54






  • 1





    dict.results[0].state_name

    – Akshay Gaonkar
    Mar 8 at 6:59






  • 1





    Or Dim state As String = jss.Deserialize(Of Rootobject)(rawresp).results(0).state_name

    – Jimi
    Mar 8 at 7:05












  • Hi @Jimi - Trying your way produces the following error 'Public Property results As Result' has no parameters and its return type cannot be indexed

    – The Newbie
    Mar 8 at 7:08












  • 1





    Try Dim dict = jss.Deserialize(Of Rootobject)(rawresp) instead Of Result

    – Akshay Gaonkar
    Mar 8 at 6:52











  • Would I then get the result with something like dict.results.state_name ? Because its saying that the result is not supported for deserialization of an array

    – The Newbie
    Mar 8 at 6:54






  • 1





    dict.results[0].state_name

    – Akshay Gaonkar
    Mar 8 at 6:59






  • 1





    Or Dim state As String = jss.Deserialize(Of Rootobject)(rawresp).results(0).state_name

    – Jimi
    Mar 8 at 7:05












  • Hi @Jimi - Trying your way produces the following error 'Public Property results As Result' has no parameters and its return type cannot be indexed

    – The Newbie
    Mar 8 at 7:08







1




1





Try Dim dict = jss.Deserialize(Of Rootobject)(rawresp) instead Of Result

– Akshay Gaonkar
Mar 8 at 6:52





Try Dim dict = jss.Deserialize(Of Rootobject)(rawresp) instead Of Result

– Akshay Gaonkar
Mar 8 at 6:52













Would I then get the result with something like dict.results.state_name ? Because its saying that the result is not supported for deserialization of an array

– The Newbie
Mar 8 at 6:54





Would I then get the result with something like dict.results.state_name ? Because its saying that the result is not supported for deserialization of an array

– The Newbie
Mar 8 at 6:54




1




1





dict.results[0].state_name

– Akshay Gaonkar
Mar 8 at 6:59





dict.results[0].state_name

– Akshay Gaonkar
Mar 8 at 6:59




1




1





Or Dim state As String = jss.Deserialize(Of Rootobject)(rawresp).results(0).state_name

– Jimi
Mar 8 at 7:05






Or Dim state As String = jss.Deserialize(Of Rootobject)(rawresp).results(0).state_name

– Jimi
Mar 8 at 7:05














Hi @Jimi - Trying your way produces the following error 'Public Property results As Result' has no parameters and its return type cannot be indexed

– The Newbie
Mar 8 at 7:08





Hi @Jimi - Trying your way produces the following error 'Public Property results As Result' has no parameters and its return type cannot be indexed

– The Newbie
Mar 8 at 7:08












2 Answers
2






active

oldest

votes


















1














Use List Of Objects instead of array in your class. I have done two changes One in the rootobject for results and other in the result class for bbox



Public Class Rootobject
Public Property input As Input
Public Property results As List(Of Result)
End Class

Public Class Input
Public Property lat As Single
Public Property lon As Single
End Class

Public Class Result
Public Property block_fips As String
Public Property bbox As List(Of Single)
Public Property county_fips As String
Public Property county_name As String
Public Property state_fips As String
Public Property state_code As String
Public Property state_name As String
Public Property block_pop_2015 As Integer
Public Property amt As String
Public Property bea As String
Public Property bta As String
Public Property cma As String
Public Property eag As String
Public Property ivm As String
Public Property mea As String
Public Property mta As String
Public Property pea As String
Public Property rea As String
Public Property rpc As String
Public Property vpc As String
End Class


Then access the properties



 Dim jss As New JavaScriptSerializer()
Dim dict = jss.Deserialize(Of Rootobject)(MyJSON)
MsgBox(dict.results.FirstOrDefault().state_name)





share|improve this answer























  • List Of Object worked perfectly fine. Thank you, I never seem to have good luck with JSON or XML

    – The Newbie
    Mar 8 at 7:27


















1














Same, using the Newtonsoft.Json namespace.



The classes properties have being assigned new names, using a <JsonProperty> attribute.

Also, the Results property is modified to return a List(Of Result).



The deserialization is pretty simple and straightforward:

You can use the Visual Studio NuGet Package Manager to install Newtonsoft.Json.



Imports Newtonsoft.Json

Dim latlonResults As RootObject = JsonConvert.DeserializeObject(Of RootObject)(JSON)
Dim state As String = latlonResults.Results(0).StateName


or access a property directly while deserializing:



Dim state As String = JsonConvert.DeserializeObject(Of RootObject)(JSON).Results(0).StateName


Refactored classes:



Public Class RootObject 
<JsonProperty("input")>
Public Property Input() As Input

<JsonProperty("results")>
Public Property Results() As List(Of Result)
End Class

Public Class Input
<JsonProperty("lat")>
Public Property Lat() As Double

<JsonProperty("lon")>
Public Property Lon() As Double
End Class

Public Class Result
<JsonProperty("block_fips")>
Public Property BlockFips() As String

<JsonProperty("bbox")>
Public Property Bbox() As List(Of Double)

<JsonProperty("county_fips")>
Public Property CountyFips() As Long

<JsonProperty("county_name")>
Public Property CountyName() As String

<JsonProperty("state_fips")>
Public Property StateFips() As Long

<JsonProperty("state_code")>
Public Property StateCode() As String

<JsonProperty("state_name")>
Public Property StateName() As String

<JsonProperty("block_pop_2015")>
Public Property BlockPop2015() As Long

<JsonProperty("amt")>
Public Property Amt() As String

<JsonProperty("bea")>
Public Property Bea() As String

<JsonProperty("bta")>
Public Property Bta() As String

<JsonProperty("cma")>
Public Property Cma() As String

<JsonProperty("eag")>
Public Property Eag() As String

<JsonProperty("ivm")>
Public Property Ivm() As String

<JsonProperty("mea")>
Public Property Mea() As String

<JsonProperty("mta")>
Public Property Mta() As String

<JsonProperty("pea")>
Public Property Pea() As String

<JsonProperty("rea")>
Public Property Rea() As String

<JsonProperty("rpc")>
Public Property Rpc() As String

<JsonProperty("vpc")>
Public Property Vpc() As String
End Class





share|improve this answer























  • Thank you for your answer as well. I wish I can mark both as the accepted answer, but at least it will help someone else in the future if they happen to see this post!

    – The Newbie
    Mar 8 at 17:02











  • Sure, I posted it for your conveniece first and, of course, for anyone else interested. About the Visual Studio tool: it's a really simplified tool. You may not get good results when the JSON is slightly more complex. You could use some on-line services. For VB.Net, for example, JSON Utils. But I suggest QuickType: it doesn't have a VB.Net JSON converter, but it's really, well, precise. Also, JSON Formatter & Validator, it's a JSON validator/prettify tool.

    – Jimi
    Mar 8 at 19:37










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55058108%2fhow-do-you-parse-this-json-data%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Use List Of Objects instead of array in your class. I have done two changes One in the rootobject for results and other in the result class for bbox



Public Class Rootobject
Public Property input As Input
Public Property results As List(Of Result)
End Class

Public Class Input
Public Property lat As Single
Public Property lon As Single
End Class

Public Class Result
Public Property block_fips As String
Public Property bbox As List(Of Single)
Public Property county_fips As String
Public Property county_name As String
Public Property state_fips As String
Public Property state_code As String
Public Property state_name As String
Public Property block_pop_2015 As Integer
Public Property amt As String
Public Property bea As String
Public Property bta As String
Public Property cma As String
Public Property eag As String
Public Property ivm As String
Public Property mea As String
Public Property mta As String
Public Property pea As String
Public Property rea As String
Public Property rpc As String
Public Property vpc As String
End Class


Then access the properties



 Dim jss As New JavaScriptSerializer()
Dim dict = jss.Deserialize(Of Rootobject)(MyJSON)
MsgBox(dict.results.FirstOrDefault().state_name)





share|improve this answer























  • List Of Object worked perfectly fine. Thank you, I never seem to have good luck with JSON or XML

    – The Newbie
    Mar 8 at 7:27















1














Use List Of Objects instead of array in your class. I have done two changes One in the rootobject for results and other in the result class for bbox



Public Class Rootobject
Public Property input As Input
Public Property results As List(Of Result)
End Class

Public Class Input
Public Property lat As Single
Public Property lon As Single
End Class

Public Class Result
Public Property block_fips As String
Public Property bbox As List(Of Single)
Public Property county_fips As String
Public Property county_name As String
Public Property state_fips As String
Public Property state_code As String
Public Property state_name As String
Public Property block_pop_2015 As Integer
Public Property amt As String
Public Property bea As String
Public Property bta As String
Public Property cma As String
Public Property eag As String
Public Property ivm As String
Public Property mea As String
Public Property mta As String
Public Property pea As String
Public Property rea As String
Public Property rpc As String
Public Property vpc As String
End Class


Then access the properties



 Dim jss As New JavaScriptSerializer()
Dim dict = jss.Deserialize(Of Rootobject)(MyJSON)
MsgBox(dict.results.FirstOrDefault().state_name)





share|improve this answer























  • List Of Object worked perfectly fine. Thank you, I never seem to have good luck with JSON or XML

    – The Newbie
    Mar 8 at 7:27













1












1








1







Use List Of Objects instead of array in your class. I have done two changes One in the rootobject for results and other in the result class for bbox



Public Class Rootobject
Public Property input As Input
Public Property results As List(Of Result)
End Class

Public Class Input
Public Property lat As Single
Public Property lon As Single
End Class

Public Class Result
Public Property block_fips As String
Public Property bbox As List(Of Single)
Public Property county_fips As String
Public Property county_name As String
Public Property state_fips As String
Public Property state_code As String
Public Property state_name As String
Public Property block_pop_2015 As Integer
Public Property amt As String
Public Property bea As String
Public Property bta As String
Public Property cma As String
Public Property eag As String
Public Property ivm As String
Public Property mea As String
Public Property mta As String
Public Property pea As String
Public Property rea As String
Public Property rpc As String
Public Property vpc As String
End Class


Then access the properties



 Dim jss As New JavaScriptSerializer()
Dim dict = jss.Deserialize(Of Rootobject)(MyJSON)
MsgBox(dict.results.FirstOrDefault().state_name)





share|improve this answer













Use List Of Objects instead of array in your class. I have done two changes One in the rootobject for results and other in the result class for bbox



Public Class Rootobject
Public Property input As Input
Public Property results As List(Of Result)
End Class

Public Class Input
Public Property lat As Single
Public Property lon As Single
End Class

Public Class Result
Public Property block_fips As String
Public Property bbox As List(Of Single)
Public Property county_fips As String
Public Property county_name As String
Public Property state_fips As String
Public Property state_code As String
Public Property state_name As String
Public Property block_pop_2015 As Integer
Public Property amt As String
Public Property bea As String
Public Property bta As String
Public Property cma As String
Public Property eag As String
Public Property ivm As String
Public Property mea As String
Public Property mta As String
Public Property pea As String
Public Property rea As String
Public Property rpc As String
Public Property vpc As String
End Class


Then access the properties



 Dim jss As New JavaScriptSerializer()
Dim dict = jss.Deserialize(Of Rootobject)(MyJSON)
MsgBox(dict.results.FirstOrDefault().state_name)






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 8 at 7:23









Akshay GaonkarAkshay Gaonkar

246115




246115












  • List Of Object worked perfectly fine. Thank you, I never seem to have good luck with JSON or XML

    – The Newbie
    Mar 8 at 7:27

















  • List Of Object worked perfectly fine. Thank you, I never seem to have good luck with JSON or XML

    – The Newbie
    Mar 8 at 7:27
















List Of Object worked perfectly fine. Thank you, I never seem to have good luck with JSON or XML

– The Newbie
Mar 8 at 7:27





List Of Object worked perfectly fine. Thank you, I never seem to have good luck with JSON or XML

– The Newbie
Mar 8 at 7:27













1














Same, using the Newtonsoft.Json namespace.



The classes properties have being assigned new names, using a <JsonProperty> attribute.

Also, the Results property is modified to return a List(Of Result).



The deserialization is pretty simple and straightforward:

You can use the Visual Studio NuGet Package Manager to install Newtonsoft.Json.



Imports Newtonsoft.Json

Dim latlonResults As RootObject = JsonConvert.DeserializeObject(Of RootObject)(JSON)
Dim state As String = latlonResults.Results(0).StateName


or access a property directly while deserializing:



Dim state As String = JsonConvert.DeserializeObject(Of RootObject)(JSON).Results(0).StateName


Refactored classes:



Public Class RootObject 
<JsonProperty("input")>
Public Property Input() As Input

<JsonProperty("results")>
Public Property Results() As List(Of Result)
End Class

Public Class Input
<JsonProperty("lat")>
Public Property Lat() As Double

<JsonProperty("lon")>
Public Property Lon() As Double
End Class

Public Class Result
<JsonProperty("block_fips")>
Public Property BlockFips() As String

<JsonProperty("bbox")>
Public Property Bbox() As List(Of Double)

<JsonProperty("county_fips")>
Public Property CountyFips() As Long

<JsonProperty("county_name")>
Public Property CountyName() As String

<JsonProperty("state_fips")>
Public Property StateFips() As Long

<JsonProperty("state_code")>
Public Property StateCode() As String

<JsonProperty("state_name")>
Public Property StateName() As String

<JsonProperty("block_pop_2015")>
Public Property BlockPop2015() As Long

<JsonProperty("amt")>
Public Property Amt() As String

<JsonProperty("bea")>
Public Property Bea() As String

<JsonProperty("bta")>
Public Property Bta() As String

<JsonProperty("cma")>
Public Property Cma() As String

<JsonProperty("eag")>
Public Property Eag() As String

<JsonProperty("ivm")>
Public Property Ivm() As String

<JsonProperty("mea")>
Public Property Mea() As String

<JsonProperty("mta")>
Public Property Mta() As String

<JsonProperty("pea")>
Public Property Pea() As String

<JsonProperty("rea")>
Public Property Rea() As String

<JsonProperty("rpc")>
Public Property Rpc() As String

<JsonProperty("vpc")>
Public Property Vpc() As String
End Class





share|improve this answer























  • Thank you for your answer as well. I wish I can mark both as the accepted answer, but at least it will help someone else in the future if they happen to see this post!

    – The Newbie
    Mar 8 at 17:02











  • Sure, I posted it for your conveniece first and, of course, for anyone else interested. About the Visual Studio tool: it's a really simplified tool. You may not get good results when the JSON is slightly more complex. You could use some on-line services. For VB.Net, for example, JSON Utils. But I suggest QuickType: it doesn't have a VB.Net JSON converter, but it's really, well, precise. Also, JSON Formatter & Validator, it's a JSON validator/prettify tool.

    – Jimi
    Mar 8 at 19:37















1














Same, using the Newtonsoft.Json namespace.



The classes properties have being assigned new names, using a <JsonProperty> attribute.

Also, the Results property is modified to return a List(Of Result).



The deserialization is pretty simple and straightforward:

You can use the Visual Studio NuGet Package Manager to install Newtonsoft.Json.



Imports Newtonsoft.Json

Dim latlonResults As RootObject = JsonConvert.DeserializeObject(Of RootObject)(JSON)
Dim state As String = latlonResults.Results(0).StateName


or access a property directly while deserializing:



Dim state As String = JsonConvert.DeserializeObject(Of RootObject)(JSON).Results(0).StateName


Refactored classes:



Public Class RootObject 
<JsonProperty("input")>
Public Property Input() As Input

<JsonProperty("results")>
Public Property Results() As List(Of Result)
End Class

Public Class Input
<JsonProperty("lat")>
Public Property Lat() As Double

<JsonProperty("lon")>
Public Property Lon() As Double
End Class

Public Class Result
<JsonProperty("block_fips")>
Public Property BlockFips() As String

<JsonProperty("bbox")>
Public Property Bbox() As List(Of Double)

<JsonProperty("county_fips")>
Public Property CountyFips() As Long

<JsonProperty("county_name")>
Public Property CountyName() As String

<JsonProperty("state_fips")>
Public Property StateFips() As Long

<JsonProperty("state_code")>
Public Property StateCode() As String

<JsonProperty("state_name")>
Public Property StateName() As String

<JsonProperty("block_pop_2015")>
Public Property BlockPop2015() As Long

<JsonProperty("amt")>
Public Property Amt() As String

<JsonProperty("bea")>
Public Property Bea() As String

<JsonProperty("bta")>
Public Property Bta() As String

<JsonProperty("cma")>
Public Property Cma() As String

<JsonProperty("eag")>
Public Property Eag() As String

<JsonProperty("ivm")>
Public Property Ivm() As String

<JsonProperty("mea")>
Public Property Mea() As String

<JsonProperty("mta")>
Public Property Mta() As String

<JsonProperty("pea")>
Public Property Pea() As String

<JsonProperty("rea")>
Public Property Rea() As String

<JsonProperty("rpc")>
Public Property Rpc() As String

<JsonProperty("vpc")>
Public Property Vpc() As String
End Class





share|improve this answer























  • Thank you for your answer as well. I wish I can mark both as the accepted answer, but at least it will help someone else in the future if they happen to see this post!

    – The Newbie
    Mar 8 at 17:02











  • Sure, I posted it for your conveniece first and, of course, for anyone else interested. About the Visual Studio tool: it's a really simplified tool. You may not get good results when the JSON is slightly more complex. You could use some on-line services. For VB.Net, for example, JSON Utils. But I suggest QuickType: it doesn't have a VB.Net JSON converter, but it's really, well, precise. Also, JSON Formatter & Validator, it's a JSON validator/prettify tool.

    – Jimi
    Mar 8 at 19:37













1












1








1







Same, using the Newtonsoft.Json namespace.



The classes properties have being assigned new names, using a <JsonProperty> attribute.

Also, the Results property is modified to return a List(Of Result).



The deserialization is pretty simple and straightforward:

You can use the Visual Studio NuGet Package Manager to install Newtonsoft.Json.



Imports Newtonsoft.Json

Dim latlonResults As RootObject = JsonConvert.DeserializeObject(Of RootObject)(JSON)
Dim state As String = latlonResults.Results(0).StateName


or access a property directly while deserializing:



Dim state As String = JsonConvert.DeserializeObject(Of RootObject)(JSON).Results(0).StateName


Refactored classes:



Public Class RootObject 
<JsonProperty("input")>
Public Property Input() As Input

<JsonProperty("results")>
Public Property Results() As List(Of Result)
End Class

Public Class Input
<JsonProperty("lat")>
Public Property Lat() As Double

<JsonProperty("lon")>
Public Property Lon() As Double
End Class

Public Class Result
<JsonProperty("block_fips")>
Public Property BlockFips() As String

<JsonProperty("bbox")>
Public Property Bbox() As List(Of Double)

<JsonProperty("county_fips")>
Public Property CountyFips() As Long

<JsonProperty("county_name")>
Public Property CountyName() As String

<JsonProperty("state_fips")>
Public Property StateFips() As Long

<JsonProperty("state_code")>
Public Property StateCode() As String

<JsonProperty("state_name")>
Public Property StateName() As String

<JsonProperty("block_pop_2015")>
Public Property BlockPop2015() As Long

<JsonProperty("amt")>
Public Property Amt() As String

<JsonProperty("bea")>
Public Property Bea() As String

<JsonProperty("bta")>
Public Property Bta() As String

<JsonProperty("cma")>
Public Property Cma() As String

<JsonProperty("eag")>
Public Property Eag() As String

<JsonProperty("ivm")>
Public Property Ivm() As String

<JsonProperty("mea")>
Public Property Mea() As String

<JsonProperty("mta")>
Public Property Mta() As String

<JsonProperty("pea")>
Public Property Pea() As String

<JsonProperty("rea")>
Public Property Rea() As String

<JsonProperty("rpc")>
Public Property Rpc() As String

<JsonProperty("vpc")>
Public Property Vpc() As String
End Class





share|improve this answer













Same, using the Newtonsoft.Json namespace.



The classes properties have being assigned new names, using a <JsonProperty> attribute.

Also, the Results property is modified to return a List(Of Result).



The deserialization is pretty simple and straightforward:

You can use the Visual Studio NuGet Package Manager to install Newtonsoft.Json.



Imports Newtonsoft.Json

Dim latlonResults As RootObject = JsonConvert.DeserializeObject(Of RootObject)(JSON)
Dim state As String = latlonResults.Results(0).StateName


or access a property directly while deserializing:



Dim state As String = JsonConvert.DeserializeObject(Of RootObject)(JSON).Results(0).StateName


Refactored classes:



Public Class RootObject 
<JsonProperty("input")>
Public Property Input() As Input

<JsonProperty("results")>
Public Property Results() As List(Of Result)
End Class

Public Class Input
<JsonProperty("lat")>
Public Property Lat() As Double

<JsonProperty("lon")>
Public Property Lon() As Double
End Class

Public Class Result
<JsonProperty("block_fips")>
Public Property BlockFips() As String

<JsonProperty("bbox")>
Public Property Bbox() As List(Of Double)

<JsonProperty("county_fips")>
Public Property CountyFips() As Long

<JsonProperty("county_name")>
Public Property CountyName() As String

<JsonProperty("state_fips")>
Public Property StateFips() As Long

<JsonProperty("state_code")>
Public Property StateCode() As String

<JsonProperty("state_name")>
Public Property StateName() As String

<JsonProperty("block_pop_2015")>
Public Property BlockPop2015() As Long

<JsonProperty("amt")>
Public Property Amt() As String

<JsonProperty("bea")>
Public Property Bea() As String

<JsonProperty("bta")>
Public Property Bta() As String

<JsonProperty("cma")>
Public Property Cma() As String

<JsonProperty("eag")>
Public Property Eag() As String

<JsonProperty("ivm")>
Public Property Ivm() As String

<JsonProperty("mea")>
Public Property Mea() As String

<JsonProperty("mta")>
Public Property Mta() As String

<JsonProperty("pea")>
Public Property Pea() As String

<JsonProperty("rea")>
Public Property Rea() As String

<JsonProperty("rpc")>
Public Property Rpc() As String

<JsonProperty("vpc")>
Public Property Vpc() As String
End Class






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 8 at 7:33









JimiJimi

9,50742035




9,50742035












  • Thank you for your answer as well. I wish I can mark both as the accepted answer, but at least it will help someone else in the future if they happen to see this post!

    – The Newbie
    Mar 8 at 17:02











  • Sure, I posted it for your conveniece first and, of course, for anyone else interested. About the Visual Studio tool: it's a really simplified tool. You may not get good results when the JSON is slightly more complex. You could use some on-line services. For VB.Net, for example, JSON Utils. But I suggest QuickType: it doesn't have a VB.Net JSON converter, but it's really, well, precise. Also, JSON Formatter & Validator, it's a JSON validator/prettify tool.

    – Jimi
    Mar 8 at 19:37

















  • Thank you for your answer as well. I wish I can mark both as the accepted answer, but at least it will help someone else in the future if they happen to see this post!

    – The Newbie
    Mar 8 at 17:02











  • Sure, I posted it for your conveniece first and, of course, for anyone else interested. About the Visual Studio tool: it's a really simplified tool. You may not get good results when the JSON is slightly more complex. You could use some on-line services. For VB.Net, for example, JSON Utils. But I suggest QuickType: it doesn't have a VB.Net JSON converter, but it's really, well, precise. Also, JSON Formatter & Validator, it's a JSON validator/prettify tool.

    – Jimi
    Mar 8 at 19:37
















Thank you for your answer as well. I wish I can mark both as the accepted answer, but at least it will help someone else in the future if they happen to see this post!

– The Newbie
Mar 8 at 17:02





Thank you for your answer as well. I wish I can mark both as the accepted answer, but at least it will help someone else in the future if they happen to see this post!

– The Newbie
Mar 8 at 17:02













Sure, I posted it for your conveniece first and, of course, for anyone else interested. About the Visual Studio tool: it's a really simplified tool. You may not get good results when the JSON is slightly more complex. You could use some on-line services. For VB.Net, for example, JSON Utils. But I suggest QuickType: it doesn't have a VB.Net JSON converter, but it's really, well, precise. Also, JSON Formatter & Validator, it's a JSON validator/prettify tool.

– Jimi
Mar 8 at 19:37





Sure, I posted it for your conveniece first and, of course, for anyone else interested. About the Visual Studio tool: it's a really simplified tool. You may not get good results when the JSON is slightly more complex. You could use some on-line services. For VB.Net, for example, JSON Utils. But I suggest QuickType: it doesn't have a VB.Net JSON converter, but it's really, well, precise. Also, JSON Formatter & Validator, it's a JSON validator/prettify tool.

– Jimi
Mar 8 at 19:37

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55058108%2fhow-do-you-parse-this-json-data%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme