Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>JSON to ControlNew to Visual Studio Code? Get it now.
JSON to Control

JSON to Control

KeepaKing

|
1 install
| (0) | Free
Convert JSON to Control language structures
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

jsonToControl

How to use

Method 1

  1. Copy JSON
  2. Open Command Pallete, and find JsonToControl: Convert JSON from Clipboard
  3. Fill the box, select the option
  4. Done

Method 2

  1. Copy JSON
  2. Right click on folder or dart file
  3. Click Convert JSON from Clipboard Here
  4. Fill the box, select the option
  5. Done

Configuration via VSCode Settings

You can configure the extension through VSCode's standard settings interface:

  1. Open VSCode Settings (Ctrl+, or Cmd+, on Mac)
  2. Search for "JsonToControl" or navigate to Extensions > JsonToControl
  3. Modify any of the available settings:
    • jsontocontrol.defaultFolder: Default output folder for generated files
    • jsontocontrol.includeComments: Include comments in generated Control files
    • jsontocontrol.useTabs: Use tabs for indentation in generated files
    • jsontocontrol.tabSize: Number of spaces for indentation in generated files

More Configuration

To handle null value on generated model, you can define/change data type on pubspec.yaml

Sample

{
  "name": "Test User",
  "age": 30,
  "isActive": true,
  "address": {
    "street": "Main St",
    "city": "New York"
  }
}

Output:


/**
 * @brief Addresses structure
 * @details Auto-generated from JSON
 * @version 0.1
 * @date 11-08-2025
 */
/**
 * @brief Structure fields
 * @details Auto-generated from JSON
 * {
 *   street <string>
 *   city <string>
 *   zipCode <string>
 * }
 */
struct Addresses
{
    string      street;
    string      city;
    string      zipCode;

        public bool IsEmpty()
        {
                if (this.street != "")
                        return false;
                if (this.city != "")
                        return false;
                if (this.zipCode != "")
                        return false;
                return true;
        }

        public Addresses(mapping data = makeMapping())
        {
                this.street = mappingHasKey(data, "street") ? data["street"] : "";
                this.city = mappingHasKey(data, "city") ? data["city"] : "";
                this.zipCode = mappingHasKey(data, "zipCode") ? data["zipCode"] : "";
        }

        public mapping ToMapping(Addresses obj)
        {
                mapping data;
                data["street"] = obj.street;
                data["city"] = obj.city;
                data["zipCode"] = obj.zipCode;
                return data;
        }
};

/**
 * @brief Test_UserData structure
 * @details Auto-generated from JSON
 * @version 0.1
 * @date 11-08-2025
 */
/**
 * @brief Structure fields
 * @details Auto-generated from JSON
 * {
 *   isActive <bool>
 *   name <string>
 *   price <float>
 *   description <string>
 *   tags <dyn_string>
 *   addresses <vector<Addresses>>
 * }
 */
struct Test_UserData
{
    bool        isActive;
    string      name;
    float       price;
    string      description;
    dyn_string  tags;
    vector<Addresses>   addresses;

        public bool IsEmpty()
        {
                if (this.isActive != false)
                        return false;
                if (this.name != "")
                        return false;
                if (this.price != 0)
                        return false;
                if (this.description != "")
                        return false;
                if (dynlen(this.tags) != 0)
                        return false;
                if (!this.addresses.IsEmpty())
                        return false;
                return true;
        }

        public Test_UserData(mapping data = makeMapping())
        {
                this.isActive = mappingHasKey(data, "isActive") ? data["isActive"] : false;
                this.name = mappingHasKey(data, "name") ? data["name"] : "";
                this.price = mappingHasKey(data, "price") ? data["price"] : 0.0;
                this.description = mappingHasKey(data, "description") ? data["description"] : "";
                if (mappingHasKey(data, "tags")) {
                        this.tags = data["tags"];
                } else {
                        this.tags = makeDynString();
                }
                if (mappingHasKey(data, "addresses")) {
                        if (dynlen(data["addresses"]) > 0) {
                                for (int i = 1; i <= dynlen(data["addresses"]); i++) {
                                        this.addresses.append(new Addresses(data["addresses"][i]));
                                }
                        }
                } else {
                        this.addresses = vector<Addresses>;
                }
        }

        public mapping ToMapping(Test_UserData obj)
        {
                mapping data;
                data["isActive"] = obj.isActive;
                data["name"] = obj.name;
                data["price"] = obj.price;
                data["description"] = obj.description;
                data["tags"] = obj.tags;
                if (obj.addresses.count() > 0) {
                        dyn_mapping addressesData;
                        for (int i = 0; i < obj.addresses.count(); i++)
                                dynAppendConst(addressesData, obj.addresses.at(i).ToMapping());
                        data["addresses"] = addressesData;
                }
                return data;
        }
};

## Customize Extension Settings

You can customize the behavior of the JsonToControl extension by modifying your VSCode settings. Here are the available configuration options:

### Global Settings
Add these to your VSCode `settings.json` file (File > Preferences > Settings > Open Settings (JSON)):

```json
{
    "jsontocontrol.includeComments": true,
    "jsontocontrol.useTabs": true,
    "jsontocontrol.tabSize": 4,
    "jsontocontrol.fieldNameCase": "camelCase"
}

Configuration Options

Setting Type Default Description
jsontocontrol.includeComments boolean true Whether to include documentation comments in generated files
jsontocontrol.useTabs boolean true Use tabs for indentation instead of spaces
jsontocontrol.tabSize number 4 Number of spaces for indentation (if not using tabs). Valid range: 0-8
jsontocontrol.fieldNameCase string "camelCase" Naming convention for field names ("camelCase" or "snake_case")

Workspace Settings

You can also configure these settings on a per-workspace basis by creating or editing the .vscode/settings.json file in your project root.

Example Workspace Configuration

{
    "jsontocontrol.includeComments": true,
    "jsontocontrol.useTabs": false,
    "jsontocontrol.tabSize": 2,
    "jsontocontrol.fieldNameCase": "snake_case"
}

Note: After changing any settings, you may need to reload the VSCode window for the changes to take effect.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft