Consider the following JSON Data:
{
arr: [ { foo: 'bar', fizz: 'buzz' } ]
}
Currently the lib supports this format:
root: example
elements:
- arr:
arrItem:
arrItemPropFoo: ${foo}
arrItemPropFizz: ${buzz}
The output being:
<example>
<arr>
<arrItem>
<arrItemPropFoo>bar</arr1ItemPropFoo>
<arrItemPropFizz>buzz</arr1ItemPropFizz>
</arrItem>
</arr1>
</example>
This works but in the elements you have to have arr as the key, and subsequently this is the tag that gets generated and the item property, meaning there is no ability to use a different element, for example:
root: example
elements:
- SomeCustomArrTag:
SomeCustomArrItem:
SomeCustomArrItemPropFoo: ${foo}
SomeCustomArrItemPropFizz: ${fizz}
Ideally it would be better to allow the config above, then change the ${foo} to be a path reference to the array, something like ${arr[].foo} and ${arr[].fizz}
root: example
elements:
- SomeCustomArrTag:
SomeCustomArrItem:
SomeCustomArrItemPropFoo: ${arr[].foo}
SomeCustomArrItemPropFizz: ${arr[].fizz}
This would allow for creating referential mappings instead of explicit ones and supporting custom tags for array elements.
Open to better suggestions on the formatting of the template if the current setup is too muddy or confusing.
Consider the following JSON Data:
{ arr: [ { foo: 'bar', fizz: 'buzz' } ] }Currently the lib supports this format:
The output being:
This works but in the
elementsyou have to havearras the key, and subsequently this is the tag that gets generated and the item property, meaning there is no ability to use a different element, for example:Ideally it would be better to allow the config above, then change the
${foo}to be a path reference to the array, something like${arr[].foo}and${arr[].fizz}This would allow for creating referential mappings instead of explicit ones and supporting custom tags for array elements.
Open to better suggestions on the formatting of the template if the current setup is too muddy or confusing.