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

XML formatter pathing #3

Open
Johnbastian opened this issue Nov 5, 2019 · 0 comments
Open

XML formatter pathing #3

Johnbastian opened this issue Nov 5, 2019 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@Johnbastian
Copy link
Contributor

The treatAsArray should be fleshed out more to specify paths, since the current implementation is simple in that it will try and match any key to any specified in treatAsArray, regardless of depth, which may become an issue if/when more specific control is needed. As such, treatAsArray should accept strings that are in the format of what _.get would accept.

That said, "matching all and any" keys should still be possible, but this will need some custom implementation for doing so.

Specification proposal

* can be utilised as a wild card to indicate matching all/any, and the XML formatter will need to manually handle these. For initial implementation, there can be two primary uses for this: arrays and "all/any".

Arrays

Take for example the following object:

{
	users: [
		{
			id: 'abc123',
			emails: '[email protected]',
			...
		},
		{
			id: 'def456',
			emails: [
				'[email protected]',
				'[email protected]'
			]
			...
		},
	]
}

To indicate that emails of each object in users is what should be treated as an array, a path using the wildcard would look like users[*].emails. When the XML formatter analyses the path, seeing [*] should indicate all elements are applicable, so in this case emails from each element object is being referenced.
In the event the property doesn't exist, ignore it.

All/any

To indicate matching any and all matches of a key, something like *key could be used.
For example, in this object:

{
	test: 'abc'
	test_depth1: {
		test: 'def',
		test_depth2: {
			test: {}
		}
	}
}

If all tests keys are to be treated as arrays, specifying *test in treatAsArray should match the following paths, casting them all to arrays:

  • test
  • test_depth1.test
  • test_depth1.test_depth2.test
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

3 participants