Selection functions
var
Commentary
added in 0.0.5
Look up a variable defined in the top-level vars or varsOnce sections, optionally drilling into its subvalue with path. Vars may refer to other variables.
If you make multiple references to the same var in a single generator, you are guaranteed to get the same value each time.
Values in varsOnce are only ever evaluated once, and then locked for the duration of the generator, as the name implies.
You can use vars to generate multiple values in one shot, then drill into them with the path function modifier. 1
Examples
Retrieve a variable
Use vars to generate a fresh value for each iteration. Use varsOnce to generate values only once and then lock them.
{
    "topic": "sandbox",
    "vars": {
        "val1": {
            "_gen": "uniformDistribution",
            "bounds": [
                1,
                5
            ]
        }
    },
    "varsOnce": {
        "val2": {
            "_gen": "uniformDistribution",
            "bounds": [
                1,
                5
            ]
        }
    },
    "value": {
        "val1": {
            "_gen": "var",
            "var": "val1"
        },
        "val2": {
            "_gen": "var",
            "var": "val2"
        }
    }
}
[
    {
        "val1": 3.7365219483965153,
        "val2": 1.2570626786091843
    },
    {
        "val1": 4.723442543937035,
        "val2": 1.2570626786091843
    },
    {
        "val1": 2.108000570366219,
        "val2": 1.2570626786091843
    },
    {
        "val1": 4.074592034249822,
        "val2": 1.2570626786091843
    },
    {
        "val1": 3.0044827422576983,
        "val2": 1.2570626786091843
    }
]
Drill into a map
Use a compound structure, like a map, to generate multiple values assigned to one var. This is especially useful for choices where two or more values relate to each other.
{
    "topic": "sandbox",
    "vars": {
        "profile": {
            "_gen": "oneOf",
            "choices": [
                {
                    "luckyNumber": {
                        "_gen": "uniformDistribution",
                        "bounds": [
                            1,
                            50
                        ],
                        "decimals": 0
                    },
                    "active": false
                },
                {
                    "luckyNumber": {
                        "_gen": "uniformDistribution",
                        "bounds": [
                            50,
                            99
                        ],
                        "decimals": 0
                    },
                    "active": true
                }
            ]
        }
    },
    "value": {
        "userProfile": {
            "theNumber": {
                "_gen": "var",
                "var": "profile",
                "path": [
                    "luckyNumber"
                ]
            },
            "tags": {
                "isActive": {
                    "_gen": "var",
                    "var": "profile",
                    "path": [
                        "active"
                    ]
                }
            }
        }
    }
}
[
    {
        "userProfile": {
            "theNumber": 14,
            "tags": {
                "isActive": false
            }
        }
    },
    {
        "userProfile": {
            "theNumber": 46,
            "tags": {
                "isActive": false
            }
        }
    },
    {
        "userProfile": {
            "theNumber": 9,
            "tags": {
                "isActive": false
            }
        }
    },
    {
        "userProfile": {
            "theNumber": 2,
            "tags": {
                "isActive": false
            }
        }
    },
    {
        "userProfile": {
            "theNumber": 8,
            "tags": {
                "isActive": false
            }
        }
    }
]
Specification
JSON schema
{
    "type": "object",
    "properties": {
        "var": {
            "type": "string"
        },
        "path": {
            "type": "array",
            "items": {
                "oneOf": [
                    {
                        "type": "integer",
                        "minimum": 0
                    },
                    {
                        "type": "string"
                    }
                ]
            }
        }
    },
    "required": [
        "var"
    ]
}