I’m trying to register the value of a JSON object only when another JSON object is equal to a certain value, but I just can’t figure out how I’d do that.
For example, this is my JSON output which is registered in the variable results_var:
I'm trying to register the value of a JSON object only when another JSON
object is equal to a certain value, but I just can't figure out how I'd do
that.
For example, this is my JSON output which is registered in the variable
results_var:
Ok, I guess a little background would help. I’m using the uri module to retrieve a list of hosts in an inventory from our Tower server. It returns the JSON output below. I’ve paired it down to just the pieces I care about. There are two servers in this inventory. I’d like to retrieve the id based on the server name.
The error is caused by your "improvement". The query works fine when you keep
the backticks "`" that wrap the argument (both double and single-quotes have
already been used elsewhere in the string). The tasks below
Ah, ok, I missed that those were backticks. So because we used double-quotes to encompass the whole argument, and single-quotes to encompass the json_query argument, we cannot use single-quotes again to encompass the search string. We need to use something else, in this case backticks, to distinguish the search string?