sdawood / json-tots

JSON Template of Templates
MIT License
9 stars 4 forks source link

Object key template support #19

Closed sebastianfelipe closed 1 year ago

sebastianfelipe commented 3 years ago

Hi! I was having a look at this lib, I think it works pretty well and it is a necessary lib for a lot of use of cases. I just wondering how it can be defined this template at a key level? For example:

Consider a document defined as this

{
    "assets": [
        {
            "name": "asset-1",
                        "label": "label-1"
        },
        {
            "name": "asset-2",
                        "label": "label-2"
        }
    ]
}

And consider a template defined as this:

{
    "modules": {
        "{{assets[*].name}}": true
    }
}

I was hoping the result were:

{
    "modules": {
        "asset-1": true,
                "asset-2": true
    }
}

But the result was:

{
    "modules": {
        "{{assets[*].name}}": true
    }
}

That means the key doesn't have a template. And the other thing is it this would be possible, how can you reference the same object? For example that it would five a result like this:

{
    "modules": {
        "asset-1": "label-1",
                "asset-2": "label-1"
    }
}

I'd really appreciate your support. Thanks!