A Visual Basic .NET implementation that transforms JSON Strings into a managed .NET XDocument
Visual Basic
Latest commit 4b8fdf1 May 25, 2016 @dday9 Update README.md
Failed to load latest commit information.
.gitignore Initial commit May 25, 2016
LICENSE Initial commit May 25, 2016
README.md Update README.md May 25, 2016
json.vb Add files via upload May 25, 2016



A Visual Basic .NET implementation that converts JSON Strings into a .NET XDocument

To use the file simply add it to your project and call the JSON.Parse method.


Public Function Parse(ByVal source As String) As XDocument


  • source

    • Type: System.String
    • The JSON literal to be converted.
  • Return Value

    • Type: System.Xml.Linq.XDocument
    • An XML representation of the JSON literal. If the JSON is not parsable, then the method returns Nothing.


  1. The parser ignores whitespace. So if the JSON literal is:

    "string key": [1, 2, {
        "nested": true

    Then it gets parsed as: {"string key":[1,2,{"nested":true}]}

  2. The returned XML is a 1-to-1 translation from the JSON. Using the same example as above, the resulting XML would be:

    <array key="string key">
        <boolean key="nested">true</boolean>


The following example demonstrates the Parse method.

  Option Strict On
  Public Module Module1
      Public Sub main()
          Dim jsonLiteral As String = String.Format("{0}{1}key1{1}: [1, -2.12345E6, [true, false]], {1}key2{1}: {0}{1}nested object{1}: null{2}{2}", "{", """", "}")
          '{"key1": [1, -2.12345E6, [true, false]], "key2": {"nested object": null}}

          Dim jsonDocument As XDocument = JSON.Parse(jsonLiteral)
          '  <array key = "key1" >
          '    <number>1</number>
          '    <number>-2.12345E6</number>
          '    <array>
          '      <boolean>true</Boolean>
          '      <boolean>false</Boolean>
          '    </array>
          '  </array>
          '  <object key = "key2" >
          '    <boolean key="nested object">null</boolean>
          '  </object>

      End Sub

  End Module