question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JMESPath query when JSON property names have spaces

See original GitHub issue

Description

Outline the issue here: In JMESpath.org website, I’m able to run the following query: image

Here, there’s a space in one of the JSON names “d e”. This works in JMESPath website, but a similar thing fails in CLI.

Environment summary

Install Method: How did you install the CLI? (e.g. pip, interactive script, apt-get, Docker, MSI, nightly)
Answer here: Developer setup

CLI Version: What version of the CLI and modules are installed? (Use az --version)
Answer here: azure-cli (2.0.10+dev)

acr (2.0.8+dev) acs (2.0.10+dev) appservice (0.1.10+dev) backup (1.0.0+dev) batch (3.0.3+dev) billing (0.1.3+dev) cdn (0.0.6+dev) cloud (2.0.6+dev) cognitiveservices (0.1.6+dev) component (2.0.6+dev) configure (2.0.10+dev) consumption (0.1.3+dev) core (2.0.11+dev) cosmosdb (0.1.10+dev) dla (0.0.10+dev) dls (0.0.10+dev) feedback (2.0.6+dev) find (0.2.6+dev) interactive (0.3.6+dev) iot (0.1.9+dev) keyvault (2.0.8+dev) lab (0.0.8+dev) monitor (0.0.8+dev) network (2.0.10+dev) nspkg (3.0.1+dev) profile (2.0.8+dev) rdbms (0.0.5+dev) redis (0.2.7+dev) resource (2.0.10+dev) role (2.0.8+dev) sf (1.0.5+dev) sql (2.0.7+dev) storage (2.0.10+dev) taskhelp (0.1.5+dev) testsdk (0.1.0+dev) utility-automation (0.1.1) vm (2.0.10+dev)

Python (Windows) 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 16:02:32) [MSC v.1900 64 bit (AMD64)]

Python location ‘d:\MabOneSdk\azure-cli\env\Scripts\python.exe’ OS Version: What OS and version are you using?
Answer here: Windows 10 Anniversary Edition Shell Type: What shell are you using? (e.g. bash, cmd.exe, Bash on Windows)
Answer here: cmd.exe

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
jiaslicommented, Dec 31, 2020

@intlabs, what @johanste provides is correct.

To filter on subscription name, you will need to use Raw String Literals which are surrounded by single quotes (').

$ az account list --query "[?name=='Scuffy Playground 0'].id"
[
  "db4a0109-e76d-42c8-bde3-aaca23696425"
]

On the other hand, double quotes (") are for Identifiers, like:

$ az version --query '"azure-cli"'
"2.15.1"
1reaction
johanstecommented, Dec 30, 2020

Does

az account list --query "[?name=='foo bar'].id"

solve your problem?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure CLI query help - JMESPath - filter ... - Stack Overflow
Query an azure resource based on a tag key which has a space in it, and extract/project the value of a tag having...
Read more >
JMESPath Specification
Evaluate the expression on the left with the original JSON document. ... A multi-select-hash expression also requires key names to be provided, as...
Read more >
JMESPath query when JSON property names have spaces
Here, there's a space in one of the JSON names "d e". This works in JMESPath website, but a similar thing fails in...
Read more >
Filter for Specific Fields (JMESPath) [2022] | API Connector
API Connector enables the use of JMESPath, which is a powerful query language for JSON with many useful applications:.
Read more >
jmespath/chat - Gitter
Hi, I've got an object with a key which can be an empty string: {"foo": ... Basically if you have a path like...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found