go-jmespath icon indicating copy to clipboard operation
go-jmespath copied to clipboard

Does not support keys with colon (:) characters

Open marefr opened this issue 4 years ago • 2 comments

Given following JSON:

{
  "custom:groups": [
    "foo",
    "bar"
  ]
}

And the following JMESPath expression: contains(custom:groups[*], 'foo') && 'Admin' || 'Editor'

Expected expression to evaluate to "Admin".

Also tried the following expressions without success: contains("custom:groups[*]", 'foo') && 'Admin' || 'Editor' contains('"custom:groups[*]"', 'foo') && 'Admin' || 'Editor'

Doesn't work at https://jmespath.org/ either, but maybe this use case is not supported?

Ref: https://github.com/grafana/grafana/issues/22986

marefr avatar Apr 06 '20 08:04 marefr

this is similar to #58 contains(\"custom:groups\"[*], 'foo') && 'Admin' || 'Editor' should work.

nevins-b avatar Oct 06 '20 17:10 nevins-b

For anyone else stumbling on this issue the following worked for me:

role_attribute_path: contains("custom:groups"[*], 'Admin-Users') && 'Admin' || contains("custom:groups"[*], 'Grafana-Editor') && 'Editor' || 'Viewer'

weir-it-services avatar Oct 21 '20 14:10 weir-it-services