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

Json aliases feature #247

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

manland
Copy link

@manland manland commented May 5, 2015

This pull-request wants to simplify the definitions of aliases.

Here at ITK we use intensively aliases, with time our aliases.properties grownth exponentially. Lots of patterns are similare but with little changes.

So we have implemented a json parser, and we have added variable feature.

Specifications :

  • the yoga_aliases directory in ressources directory contains the definitions in multiple files ending by json
  • a file can have multiple aliases and/or multiple variables
  • a file contains a single json object
  • the property of this object must have its name starts by $ for aliase and @ for variable
  • the value of each property is an array
  • each array can contain string for local value, or object for child value

Examples (from tests) :

from

$child=test,child(value)

to

{
  "$child": [
    "test",
    {
      "child": ["value"]
    }
  ]
}

Or from

$children=test,child(value,value2),child2(value3,child3(*))

to

{
  "$children": [
    "test",
    {
      "child" : [
        "value", 
        "value2"
      ]
    },
    {
      "child2": [
        "value3", 
        {
          "child3": ["*"]
        }
      ]
    }
  ]
}

And with variables :

{
  "@variable": [
    "test", 
    "test2"
  ],
  "$variable": [
    "testvar",
    {
      "childvar": [
        "child",
        "@variable"
      ]
    }
  ]
}

Could be represented as :

$variable=testvar,childvar(child,test,test2)

More complex variables can be used.

The JSON files must be in yoga_aliases directory in the ressources directory.

It can contain all files you want, the name of file is not used, but it needs to finish by .json.

We use a file, for a view in our application, and each file contains all requests aliases for this view.

A variable can be defined in one file and used in an other one. And a file can contain only aliases or only variables, it's as you want.

To resume :

  • src/main/ressources/yoga_aliases
    • view1.json
      • alias1
        • childName
      • use variable2
      • alias2
        • use variable1
    • mainVariables.json
      • definition of variable1
    • view2.json
      • definition of variable2

@eric-taix
Copy link

+1 Great addition

@kentongray
Copy link
Contributor

very interesting, hoping to see some life in this project!

@julien-lafont
Copy link

+1, very interesting feature!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants