Answered Trying to parse json, I can't find JavaScriptSerializer

robertb_NZ

Well-known member
Joined
May 11, 2010
Messages
146
Location
Auckland, New Zealand
Programming Experience
10+
I have read a .json file from https://petstore.swagger.io/v2/swagger.json that is quite complex, and I'm trying to find out how to parse it. From Stack Overflow I think I need JavaScriptSerializer, which is in System.Web.Script.Serialization, but when I write
Imports System.web. ???
there is no .script dll, so of course I can't write
VB.NET:
Dim jss As New JavaScriptSerializer()

I am using VS 2017, configured to target .NET framework 4.

How do I solve this issue? Is JavaScriptSerializer the appropriate approach, or should I use something else? I'd prefer to stick with "Microsoft standard" libraries.

Thank you, Robert Barnes
 
Last edited:

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,345
Location
Sydney, Australia
Programming Experience
10+
There's no use importing a namespace if you haven't referenced the assembly the type is declared in. Follow the Blog link in my signature below and check out my post on Assemblies & Namespaces, then look up the type of interest in the documentation:

 

robertb_NZ

Well-known member
Joined
May 11, 2010
Messages
146
Location
Auckland, New Zealand
Programming Experience
10+
John, I looked up your blog, and eventually found the article that you referred to (you might have given me its URL!). I added a reference to System.web.extensions, and now I was able to write Imports system.web.script.serialzation, so now I can continue. Thank you.
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,345
Location
Sydney, Australia
Programming Experience
10+
John, I looked up your blog, and eventually found the article that you referred to (you might have given me its URL!).
I might have, but then I would have had to follow the Blog link and look through the posts to find the right one. You're just as capable of that as I am. It's not like there's loads of posts there. If there were then I would have provided a direct link but, given how few posts there are, it should have taken less than a minute to find the right one.
 
Top Bottom