Simple JSON Parser for Visual Basic in Class

 

Example

 


        Dim JSON As New json


        JSON.Text = System.IO.File.ReadAllText("C:\installer.json").Replace(vbCr, "").Replace(vbLf, "")

        Dim p() As String = New String() {"0", "devices", "0"}

        Dim v As json_value = JSON.Value(p, True)

        Console.WriteLine(JSON.Count.ToString

 

 

json_type in json_value

     null = 0

     bool, numeric, text  in json_value.VALUE

     array  in json_value.VALUES

 

' Read all values

Dim v() as json_value = JSON.Value()

 

' Read specific value

' Path should be list of ID in level, array ID is 0 ~ nn

Dim v1 as json_value = JSON.Value(path() as string)

 

' Read specific value, ignore case of ID while compare

Dim v1 as json_value = JSON.Value(path() as string, True)

 

if can not find a data using IDs, it will return nothing.

if found a data, check json_value.type, and handle the data