Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

VS 2010 JSON to ....

$
0
0
Afternoon Everyone,

I have been working on this app for awhile now and most of the inputs I have had to read are XML which are all working very nicely however there is something I have never come acrss before apart from hearing of it I have never had any interaction with it and that is JSON!

I have been looking on the net for over an hour and I am completly lost at how to translate from JSON so I can use values contained within it. More specifically I am trying to query the Apply itune stores database for track information. Here is an example of one of the returned JSON strings:

Code:



{
 "resultCount":1,
 "results": [
{"wrapperType":"track", "kind":"song", "artistId":255772678, "collectionId":270137469, "trackId":270137520, "artistName":"Hadouken!", "collectionName":"Love, Sweat and Beer - EP", "trackName":"Girls", "collectionCensoredName":"Love, Sweat and Beer - EP", "trackCensoredName":"Girls", "artistViewUrl":"https://itunes.apple.com/gb/artist/hadouken!/id255772678?uo=4", "collectionViewUrl":"https://itunes.apple.com/gb/album/girls/id270137469?i=270137520&uo=4", "trackViewUrl":"https://itunes.apple.com/gb/album/girls/id270137469?i=270137520&uo=4", "previewUrl":"http://a717.phobos.apple.com/us/r1000/113/Music/b2/e8/f8/mzm.xrpvmzgz.aac.p.m4a", "artworkUrl30":"http://a176.phobos.apple.com/us/r1000/040/Music/20/98/3c/mzi.azgszqgw.30x30-50.jpg", "artworkUrl60":"http://a240.phobos.apple.com/us/r1000/040/Music/20/98/3c/mzi.azgszqgw.60x60-50.jpg", "artworkUrl100":"http://a1585.phobos.apple.com/us/r1000/040/Music/20/98/3c/mzi.azgszqgw.100x100-75.jpg", "collectionPrice":1.99, "trackPrice":0.79, "releaseDate":"2007-12-24T08:00:00Z", "collectionExplicitness":"notExplicit", "trackExplicitness":"notExplicit", "discCount":1, "discNumber":1, "trackCount":4, "trackNumber":3, "trackTimeMillis":205973, "country":"GBR", "currency":"GBP", "primaryGenreName":"Alternative"}]
}

This can be seen for yourself by entering https://itunes.apple.com/search?term...=music&limit=1 into your browser (works on firefox but I am told IE tries to download it as a file)

Now I need to get quite a few bits of information out of this JSON return but I have no idea how to go about it. I have seen a few things online that can convert it to a custom object also heard an Array. The other option I have heard is converting it to XML and I would be more than happy to have it in XML as I know exactly how to query that but to be honest I don't care how its stored within the application as long as I can read each attribute as and when I need it.

So for instance it would be nice to do something like

Dim Artist as string = jsonobj(jsoninput, "artistName")

which from the above JSON example my string would contain "Hadouken!"

Has anyone had any dealing with JSON and please be able to provide me some advice because I have tried a couple of libraries but im stabbing in the dark nothing I have read has made any sense.

Thanks,
Max

Viewing all articles
Browse latest Browse all 27554

Trending Articles