I have been searching this topic over the internet and found a few solutions, but I can't seem to find any for Visual Basic. I tried json from codeplex, newtonsoft but has no luck...

the json data that i want to parse is this

{"sample":[{"id":"1","fname":"kristine","lname":"reyes","address":"manila"}]}

hope anyone could help.. thanks

Dani AI

Generated

Short answer: yes — VB.NET can parse JSON. Which approach to use depends on the .NET target. For modern runtimes (.NET Core 3.0 / .NET 5+) the built-in System.Text.Json is the recommended, high-performance API; for older .NET Framework projects there are framework serializers and well-established third‑party libraries available. ’s hint about using a framework serializer is valid for framework apps, and ’s comment about many libraries is also worth keeping in mind. (learn.microsoft.com)

Practical VB example (modern recommended path): deserialize into a typed list or use the DOM for nested payloads. The example below assumes the JSON is an array of person objects (replace the source string as needed):

Imports System.Text.Json

Public Class Person
  Public Property id As String
  Public Property fname As String
  Public Property lname As String
  Public Property address As String
End Class

Dim jsonString As String = GetJsonString()
Dim people As List(Of Person) = JsonSerializer.Deserialize(Of List(Of Person))(jsonString)

If people IsNot Nothing Then
  For Each p In people
    Console.WriteLine(p.fname & " " & p.lname)
  Next
End If

If the JSON is wrapped inside a root object, use JsonDocument to locate the array and enumerate it. Note: Visual Basic has a few limitations when using some low-level System.Text.Json APIs (for example, writing custom converters that use ref structs); see the VB support notes. (learn.microsoft.com)

Common pitfalls and quick fixes: missing assembly/reference or wrong target framework (System.Web classes are part of full .NET Framework, not .NET Core), forgetting to add the NuGet package (for third‑party libraries), or feeding invalid/HTML‑encoded JSON. Installing the popular Json.NET (Newtonsoft) package via NuGet is straightforward (Install-Package Newtonsoft.Json or dotnet add package Newtonsoft.Json) and often fixes compatibility issues on older frameworks. (stackoverflow.com)

Useful shortcuts: use Visual Studio’s Paste JSON as Classes to generate VB types from JSON quickly, or deserialize to the DOM to inspect unknown payloads before creating types. For legacy scenarios, DataContractJsonSerializer and the framework serializer remain options. These tips make it easier to isolate where “no luck” comes from (framework mismatch, missing reference, or malformed JSON). (learn.microsoft.com)

Recommended Answers

All 3 Replies

There is litJson but I haven't personally tried it. I think it is from .Net frame work 3.5 so its not too old. And there is the JavaScriptSerializer class introduced in 3.5 which is apparently OK (again, I haven't used it myself).

ahh i am aware of the existence of the JavaScriptSerializer but i don't know how to use it....

http://www.json.org/ has a giant list of libraries. You might look under "C#"; the language doesn't matter as long as it targets the .NET platform.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.