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
1 answer

Check conditions for all keys in a nested data using jmespath, rectify "leaning toothpick syndrome"

I've been trying to check conditions for all nodes, ('Config state '=='NSHUT' and ('State '=='OPERATIONAL' or 'State '=='IOS XR RUN'))` I am expecting a single boolean value after the check. Following is the nested dictionary I'm trying this on: { …
alalinaci
  • 31
  • 4
1
vote
1 answer

How do you use JSON_QUERY with null json array inside of json object?

SELECT JSON_query([json], '$') from mytable Returns fine the contents of [json] field SELECT JSON_query([json], '$.Guid') from mytable Returns null SELECT JSON_query([json], '$.Guid[1]') from mytable Returns null I've also now tried: SELECT…
user713813
  • 775
  • 1
  • 8
  • 20
1
vote
2 answers

How to loop array of objects from table column?

Table columns : id --------- details My table column details has json object like "data" : [ { "name" : "luke", "dob" : "12-10-90", "addr" : "sample1", }, { "name" : "sam", "dob" : "12-10-88", "addr" : "sample2" } ] I…
DLV
  • 553
  • 2
  • 6
  • 17
1
vote
2 answers

Use json_query in Ansible to query a list of dictionaries contained within a list of dictionaries

I am having trouble using json_query to search the below data structure from which I want to create two separate lists. List 1 should contain the name key from each dictionary for entries whose members list contains the subPath key AND whose value…
Kris Reese
  • 111
  • 1
  • 1
  • 8
1
vote
2 answers

Read Json Value from a SQL Server table

I have a Json value stored in SQL server table as ntext: JSON (column: json_val): [{"prime":{"image":{"id":"123","logo":"","productId":"4000","enable":true},"accountid":"78","productId":"16","parentProductId":"","aprx":"4.599"}}] select…
kayeesp
  • 55
  • 2
  • 9
1
vote
1 answer

How to use json_query with integer

Hello Developer Community! I'm currently working on developing some Ansible playbooks to manage Citrix NetScaler configuration and would like to ask for some help about the following. I have the following data structure defined in a variable file…
Belabacsi
  • 121
  • 2
  • 10
1
vote
1 answer

Get values from JSON - SQL Server

I have the following JSON: [ { "email_id": 1598819368, "email": "test01@abc.net" }, { "email_id": 1598819369, "email": "test02@abc.net" }, { "email_id": 1598819370, "email": "test03@abc.net" }, { "email_id":…
Smiley
  • 3,207
  • 13
  • 49
  • 66
1
vote
1 answer

Complex JSON and Ansible JSON_QUERY syntax

i have complex result in JSON format and struggling to extract values out of it. I tested the JSONpath online evaluator https://jsonpath.com/ where i can just simply type $.[*].toPort and get the list of requested variables. I've tried to use the…
Marek
  • 127
  • 1
  • 8
1
vote
1 answer

ansible json_query multiple values

From a prior GET api call in ansible I'm getting a json result back. The api call would look something like this: - name: Refresh Datadog monitors list uri: url: http://my.api.com return_content: yes method: GET status_code: 200 …
WarrenG
  • 1,750
  • 12
  • 20
1
vote
2 answers

json_query filter list of dicts which has value in a list

I have a list of dict mydicts=[{name: foo, data: 1}, {name: foo1, data: 3}, {name: bar, data: 2}] and a list of names names=[foo, foo1, mars, jonh] I want to create the list of dict only contains names in the list. I know if I want to select single…
Wang
  • 7,250
  • 4
  • 35
  • 66
1
vote
1 answer

Problematic json_query syntax error on a field containing either all numeric values or non-numeric values

When I execute the ansible task, I get the following: fatal: [baseserver2.jlhimpel.net]: FAILED! => {"msg": "JMESPathError in json_query filter plugin:\ninvalid token: Parse error at column 59, token "32" (NUMBER), for…
dubby
  • 51
  • 1
  • 6
1
vote
1 answer

SQL server: select all json array elements using JSON_QUERY

I have a column myColumn in myTable table with this value: "6285":[ { "75963":{"lookupId":"54","value":"0","version":null}, "75742":{"lookupId":"254","value":"991","version":null} } ] I need to write…
1
vote
1 answer

ansible json_query How to define default value to missing key

I've got some variables: vars: foo: - {name: "bar", path: "/tmp"} - {name: "zob" } default: "/home" I'd like to make json_query that extracts name and path, and when path is not defined takes a default value. The result I…
Raoul Debaze
  • 466
  • 1
  • 8
  • 24
1
vote
2 answers

Get two values ​from the same table

I have a table called Register Id, Type_status, Status, Description Example: ID Type_status Status Description 1 8000 8017 test And i have a table called History with the following structure Id, Id_Register,…
sioesi
  • 497
  • 1
  • 5
  • 20
1
vote
0 answers

Trying to list AWS instances that older than X days, and their "Name" tag starts with a particular string

I am trying to write a JMSEpath query to return a list of AWS EC2 instances that are older than X days and begin with a particular string. Here's the command I am trying using the AWS CLI: date +'%Y-%m-%d' --date="3 days ago" | xargs -I {} aws ec2…