Giter Site home page Giter Site logo

vb6jsonx's Introduction

vb6jsonx

Vb6jsonx is a COM component that using VBA-JSON module. It increases the simplicity and usability of creating or querying JSON objects.

  • Dictionary is wrapped to JsonObject,Collection is wrapped to JsonArray.
  • The simplicity of creating objects.
  • Query the object value by a path string.

Special Notice

About source file [JsonConverter.bas] , I copied it from VBA-JSON and have made modifications. If you have no special requirements, please replace it with the original source file. Thanks for VBA-JSON, a beautiful JSON parsing module.

Installing

First register vb6jsonx.dll using regsvr32.exe, and then reference it in your project.

Examples

Public Function Creating() As String
    Dim i As Long
    Dim Request As New JsonObject

    With Request.ReNew() 
        .AddString "name", "bearx"
        .AddNumber "weight", 61
        .AddBoolean "sex", True
        .AddNull "xxx"

        With .NewObject("subobject")
            .AddString "item1", "a"
            .AddNumber "item2", 123.456
        End With

        With .NewArray("love")
            .AddString "music"
            .AddString "painting"
        End With
        
        With .NewArray("detail")
            For i = 1 To 5
                With .NewObject()
                    .AddNumber "ID", i
                    .AddString "memo", "**成都" & i
                    .AddString "create-date", Now
                    .AddNull "xxx"
                End With
            Next i
        End With
    End With
        
    Creating = Request.ToJSON()
    
End Function

Public Sub Querying()
    Dim Request As New JsonObject
    Dim queryArray As New JsonArray
    Dim queryObject As New JsonObject
    
    Dim jsonStr As String
    
    jsonStr = Creating()
    
    Request.OfJSON jsonStr
    
    Debug.Print Request.Query("name")
    Debug.Print Request.Query("subobject.item1")
    Debug.Print Request.Query("subobject.item2")
    Debug.Print Request.Query("detail.{COUNT}")
    Debug.Print Request.Query("detail.(1).memo")
    
    Set queryArray.NativeObject = Request.Query("detail")
    Debug.Print queryArray.Query("(1).memo")
    Set queryObject.NativeObject = queryArray.Query("(1)")
    Debug.Print queryObject.Query("memo")
    
    Debug.Print Request.ToJSON(Request.Query("detail"))
    Debug.Print Request.ToJSON(Request.Query("detail.(1)"))
    Debug.Print Request.ToJSON(, 2)
        
    Debug.Print Request.ToUrlEncoder()
End Sub

vb6jsonx's People

Contributors

bearx2004 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.