Questions tagged [json-query]

Use this tag for tasks involving queries against a JSON document, such as extracting JSON components from a JSON text. The tag can also be used for query languages intended for specifying such queries.

254 questions
1
vote
3 answers

How to remove null and replace with a string value in ansible

How to remove null and replace with a string novlaue? I have below output stored in variable out1 { "out1": [ [ { "destination": "dest-a", "interface": "e1/1", "metric": "10", …
netv
  • 165
  • 2
  • 12
1
vote
1 answer

Getting error Object of type set is not JSON serializable while executing my ansible script

My scenario is a bit similar to the one mentioned here but a bit difference, let me take same example mentioned in above question solution by Vladimir Botka , added name:c and name:d block output: - Name: A source: [a, b, c, a, b, c] dest:…
nauto
  • 49
  • 4
1
vote
2 answers

JSON Query with wildcard?

I am new with JSON Query, trying to do a simple task but I could not find a solution online that I got working. I have a json document like this: [ { "folder" : "User/Admin/UserA", "User" : "Linda" }, { "folder" :…
SahnAlbert
  • 11
  • 1
1
vote
1 answer

Getting null while using ansbile json_query when key value is not array

I have below data: { "msg": [ { "country": { "city": { "county": [ { "zipcode": "code1", "address": "add1" }, { "zipcode": "code2", …
nauto
  • 49
  • 4
1
vote
1 answer

How to render/parse ansible output using json_query, getting null value

I have below output3.msg, how to get the desired output mentioned below? Please help in the syntax, check the one i have and suggest any modifications.I am in learning phase apologies for any mistakes Thank you. output3.msg { "msg": [ …
netv
  • 165
  • 2
  • 12
1
vote
1 answer

Ansible loop through json output and add indexing

I've been trying to figure out for hours how to do the following with Ansible, and looping through a JSON output. Let me explain, here is my playbook: - hosts: myhosts connection: local gather_facts: yes tasks: - name: set_fact …
ayuuk ja'ay
  • 382
  • 1
  • 3
  • 13
1
vote
1 answer

Ansible - nested loop over object without knowing object/key name

I'm working on an ansible playbook, I need to get a value from a JSON API result. I want to get the value of the key "1h" without knowing the previous object (sd#eureka...), and i need to loops over all my results, and all my buckets. { …
Flo
  • 13
  • 2
1
vote
2 answers

How to replace several characters in an Ansible variable's value?

I have a variable called joomlaversion which I get using json_query. The value of joomlaversion is 4.0.2 but I am trying to swap the dots with dashes so it becomes 4-0-2 How can I substitute dots for dashes in this ansible variable value? I am using…
TryHarder
  • 2,704
  • 8
  • 47
  • 65
1
vote
1 answer

Json_query filter in Ansible

I cannot manage to make json_query work, even with the simplest examples. I have a fact old_new_nodes like: ok: [localhost] => { "msg": [ { "id_new": 2430, "id_old": 2263 }, { "id_new":…
Hector Esteban
  • 1,011
  • 1
  • 14
  • 29
1
vote
1 answer

JSON_QUERY to do a "Select Many"

I have a JSON variable that looks like this (the real one is more complex): DECLARE @myJson VARCHAR(3000) = '{ "CustomerId": "123456", "Orders": [{ "OrderId": "852", "OrderManifests": [{ …
Vaccano
  • 78,325
  • 149
  • 468
  • 850
1
vote
1 answer

How to use jmespath operator to match key on non array list

I am trying to match certain key from an ansible output/vars, and return the value of another key. Here is my vars. { "_meta": { "hostvars": { "ansibletower1_422c3aed-780c-8c33-3054-d32e330c9285": { …
sloweriang
  • 308
  • 4
  • 19
1
vote
0 answers

Pull out varying Key with values in JMESPATH

I manage to pull out some interface stats using Cisco genie and below is the JSON (apology for the long JSON). As you can see, the Interface name is not static. Can I know how do I pull out the Interface Name together with other stats using…
Michael
  • 197
  • 1
  • 2
  • 10
1
vote
1 answer

How to achieve generic Audit.NET json data processing?

I am using Audit.Net library to log EntityFramework actions into a database (currently everything into one AuditEventLogs table, where the JsonData column stores the data in the following Json format: { "EventType":"MyDbContext:test_database", …
swarts97
  • 59
  • 6
1
vote
1 answer

Convert select result that has JSON field to JSON and use that data with JSON_VALUE()

I have a table that has some columns. One of these columns stores data in JSON format. I select a row from this table with FOR JSON AUTO. My problem is that SQL Server puts quotations around the value of JSON properties but I don't want this;…
1
vote
1 answer

Ansible search a list and if a match is found append value as a new value to the dict

I've a dictionary that I'm gathering through an API that looks like below, ok: [localhost] => { "filtered_inventory": [ { "Manufacturer": "", "Name": "daughtercard 0/0/CPU0", "Serial_number":…
smenk
  • 79
  • 6