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

Indexing an array #3

Closed
ZipZamZappem opened this issue Aug 1, 2018 · 6 comments
Closed

Indexing an array #3

ZipZamZappem opened this issue Aug 1, 2018 · 6 comments
Assignees

Comments

@ZipZamZappem
Copy link

I want this:
[
{
"index": 0,
"name": "a",
"state": "up"
},
{
"index": 1,
"name": "b",
"state": "down"
},
{
"index": 2,
"name": "c",
"state": "up"
}
]

From this:
{
"people": [
{
"name": "a",
"state": {"name": "up"}
},
{
"name": "b",
"state": {"name": "down"}
},
{
"name": "c",
"state": {"name": "up"}
}
]
}

But there is no '@.index' to allow this to work:
people[].{"index":@.index,"name":name, "state":state.name}

I realize this is not strictly a query function but AFAIK the items in a JSON list are ordered so it would not be arbitrary to associate a fixed index to each item.

Is there already a way to get this information?

@jdevillard
Copy link
Owner

Hello,

this is not in the original specification but would be usefull.
@.index could not be an option because we can't have an index property in the JSON Source.

We will check what keyword we can add for this.

@ZipZamZappem
Copy link
Author

2 random thoughts: 'ndx' or 'pos'
longshot: 'indice'

@ZipZamZappem
Copy link
Author

A colleague suggested: 'offset'

@springcomp
Copy link
Collaborator

Thanks for the feedback.
I would first try an steer the official specification to include this before integrating non-official extensions.

@ZipZamZappem
Copy link
Author

How does one go about proposing changes to the official specification?

@springcomp
Copy link
Collaborator

I think you must head over to the official site and write a pull request to the spec.
Similar to this one.

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

No branches or pull requests

3 participants