I'm using the jsonpath in task.json for a custom task in a azure devops extension.
to simplify the problem, I have a json returned by an azure devops api
{"count":1,"value":[
{"variables":{"version":{"value":"2.5.6"},
"deploymentUser":{"value":"test"},
"password":{"value":null,"isSecret":true}},
"id":48,
"type":"Vsts",
"name":"myVariableGroup",
"modifiedOn":"2019-08-27T19:52:43.6466667Z",
"isShared":false,
"variableGroupProjectReferences":null}
]
}
I need a jsonpath to return the name of variables
[version,deploymentUser,password]
I read the syntax here https://support.smartbear.com/alertsite/docs/monitors/api/endpoint/jsonpath.html There is no option to select the property names. I remember somewhere i read some functions could be appear in the jsonpath something like .keyvalue()
$.value[?(@.type=='Vsts')].variables[*].keyvalue().name
any idea?
Only some implementations support it. It's not part of the original JSONPath spec
Jayway JSONPath - Java
$.value[?(@.type=='Vsts')].variables.keys()
Test Site: https://jsonpath.herokuapp.com/
JSONPath Plus - Javascript
$.value[?(@.type=='Vsts')].variables.*~
Test site: https://jsonpath.com/