#
Contextual reference this and parent
The power of your schema lies in its ability to reference other parts of the data structure. You have two contextual references available:
<this.
: Allows you to access values within the nearest object context.
<parent.
: Grants access to values in the entire generated schema.
#
Usage
#
<this.
In your schema, <this.nested.object>
references the nested.object field within the same object. This lets you reuse values within the same object. For example:
{
"value": "John Doe",
"label": "<this.nested.object>",
"nested": {
"object": "Employee"
}
}
This will generate:
{
"value": "John Doe",
"label": "Employee",
"nested": {
"object": "Employee"
}
}
#
<parent.
The <parent.
reference allows you to access values from other parts of the generated schema. For instance:
{
"parentField": "Parent Value",
"child": {
"value": "Child Value",
"combined": "<parent.parentField> - <this.value>"
}
}
This will generate:
{
"parentField": "Parent Value",
"child": {
"value": "Child Value",
"combined": "Parent Value - Child Value"
}
}
Using schemas for dynamic data generation with contextual references like <this.
and <parent.
provides powerful flexibility. You can create complex data structures with interdependencies, making it easier to simulate real-world scenarios in your testing or development processes. Understanding how to leverage these references effectively will enable you to generate diverse and realistic data effortlessly.