Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to override text (atom) node with an array or an object node #159

Open
dakusui opened this issue May 24, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@dakusui
Copy link
Owner

dakusui commented May 24, 2022

Currently if a text node and an object (or an array) node are found at the same path during inheritance processing, an error will be reported.
This behavior is not sufficiently flexible if we want to define a following node in order to force users to define a certain node.

base.json

{
    "mandatoryNode": "eval:$(error Please define this node!)"
}

Because the following file results in an error.

test.json

{
    "$extends": [ "base.json" ],
    "mandatoryNode": {
      "attr": "value"
    }
}

We want the following feature.
In case type mismatch happens, to an object node, an entry "$type": "object".
If it is an atom node, instead, the node will be converted into the following one.

{
    "$type": "atom",
    "$atomValue": "original atom value comes here"
}

If it is an array,

{
    "$type": "array",
    "$arrayValue": ["original", "values", "come", "here"]
}

If it is an object,

{
     "$type": "object",
     "originalKey1": "originalValueForOriginalKey1StaysHere",
     "originalKey2": "originalValueForOriginalKey2StaysHere",
    "...": "..."
}

Then merging will be performed.
But, note that

  • $atomValue will be removed before the "templating"(evaluation) stage is executed, unless the $type is atom.
  • Similarly, $arrayValue will be removed, unless the $type is array.
@dakusui dakusui added the enhancement New feature or request label May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant