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

Explain how to concat-fields / extract more than one field as key/value in a variable #89

Closed
domdorn opened this issue Apr 2, 2021 · 3 comments
Labels
type/feature-request Requested new feature or enhancement

Comments

@domdorn
Copy link

domdorn commented Apr 2, 2021

I have a json structure like this

{
 "items": [ 
  { "id": 5, "name": "Vienna" }, 
  { "id": 6, "name": "Salzburg"}
 
 ]
 ..
 }

I try to create a variable "countyId" which allows the user to select the county "Vienna" or "Salzburg" and use the id (5 or 6) in follow up queries.

I'm trying since more than three hours various ways of specifying my field, but I'm unable to come up with a way to get them used together, or concat them into a string so I can split them up in a regex.

These are a few of the patterns I have tried, but to no avail:

$.items[*][id,name] // this gives me 5, Vienna, 6, Salzburg
$.items[*].id // this gives me just the id, which is not user friendly
$.items[*].name // this gives me the name, which would be user friendly, but i cannot use it to resolve other parameters
$.concat($.items[*].name,$.items[*].id) // does not work, although I hoped it would ( https://stackoverflow.com/questions/45941225/how-to-concatenate-json-elements-with-jsonpath-jayway ) 
$.items[*] | { .name, .id } | @concat
$.items[*].name@string() + 'aaa'

so I need a way to either use two fields of an object for text + value or concat two fields into a string, so I can separate them using regex.

Please advice.

@marcusolsson
Copy link
Contributor

This sounds like a duplicate of #79? Could you check it out to see if that issue would fit your use case?

@marcusolsson marcusolsson added the type/feature-request Requested new feature or enhancement label Apr 4, 2021
@marcusolsson
Copy link
Contributor

I've just published v1.1.0 to the marketplace, which includes experimental support for this. Would you mind checking it out and letting me know whether it addresses your use case?

@marcusolsson
Copy link
Contributor

Closing due to inactivity.

Repository owner moved this from Triage to Done in Grafana plugins Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature-request Requested new feature or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants