Skip to content

HCL-TECH-SOFTWARE/voltscript-json-converter

Repository files navigation

VoltScript JSON Converter

VoltScript JSON Converter manages the conversion of data from JSON to VoltScript objects and back to JSON.

How it Works

As a compiled language, VoltScript cannot leverage reflection to convert the data. However, the Execute function in VoltScript can be leveraged with global variables. A string can be built for the code that needs to be run, and Execute can perform that code.

This just leaves a few complications:

  • Classes that require a custom constructor.
  • Custom converters to convert to / from specific data types
  • Custom converters that require different property names to JSON labels
  • Custom converters that need to call subs or functions instead of writing directly to properties

Using dependency management

Dependency management is available in the documentation for each project, but also aggregated here:

Authentication

You'll need a Personal Access Token to use GitHub REST APIs. You'll then need to add this to the JSON object in your atlas-settings.json, in the .vss directory of your user home directory:

    "hcl-github": {
        "type": "github",
        "token": "${env.TOKEN}"
    }

For JsonVSE downstream dependency, you'll need to sign up for the Volt MX Marketplace. Instructions are in the how-to-guide. NOTE: Ensure you log into the Volt MX Marketplace via a browser after confirming your account, to ensure the account is properly activated. Otherwise authentication to gain an access token will fail.

You'll then need to add this to the JSON object in your atlas-settings.json, in the .vss directory of your user home directory:

    "volt-mx-marketplace": {
        "type": "marketplace",
        "username": "YOUR_USERNAME",
        "password": "YOUR_PASSWORD",
        "authUrl": "https://accounts.auth.hclvoltmx.net/login"
    }

Repository

You'll need to add to your repositories object in the atlas.json of your project:

        {
            "id": "hcl-github",
            "type": "github",
            "url": "https://api.github.com/repos/HCL-TECH-SOFTWARE"
        }

Dependency

You'll need the relevant dependency to add to your dependencies or testDependencies object in the atlas.json of your project:

        {
            "library": "voltscript-json-converter",
            "version": "1.0.2",
            "module": "VoltScriptJsonConverter.vss",
            "repository": "hcl-github"
        }

Contributing

See CONTRIBUTING.md.

## Code of Conduct

See CODE_OF_CONDUCT.md.

Issues and discussions

Let's chat on OpenNTF Discord.

For long-running discussions, use Discussions area in GitHub. For bugs and feature requests specific to VoltScript Testing Framework use, Issues area.