Skip to content

Referential Arrays #1

@ksafranski

Description

@ksafranski

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions