json-query

Is there a way in Ansible to replace a dictionary value based on k:v lookup to another dictionary?

南楼画角 提交于 2021-01-28 21:02:38
问题 I have k:v dictionary of hostname: IP that I want to use in a lookup from another dictionary to replace entries matching key from 1st dictionary and replacing it with the corresponding value in 2nd dictionary; 1st: "nb_console_ip": { "office-con01": "10.20.30.100", 2nd: "nb_console_port": [ { "console": "office-con01", "hostname": "office-core01", "port": "con1" }, { "console": "office-con01", "hostname": "office-core02", "port": "con2" }, { "console": "office-con01", "hostname": "office-fw01

Ansible : filter elements containing string with JMESPath

巧了我就是萌 提交于 2021-01-28 02:11:13
问题 I want to get a list of addresses of a defined interface type. I found some info here. Here is my playbook: - name: Test JMESPath hosts: localhost gather_facts: no vars: interfaces: - name: em0 address: 10.127.37.89/29 - name: bge0 address: 10.112.171.81/28 - name: bge1 address: 10.112.171.65/28 - name: bge2 address: 10.112.171.97/28 tasks: - name: JMESPath query set_fact: result: "{{ interfaces | json_query(query) }}" vars: query: "[?name.contains(@, 'bge')].address" - debug: var: result I'd

Reading json array into rows in SQL Server

余生颓废 提交于 2020-07-02 02:03:22
问题 Given the sample json data below, how can I write a query to pull the array data all in one step? My goal is to have one row for each item in the ActionRecs array (4). My actual json is more complicated but I think this gives a good example of my goal. declare @json2 nvarchar(max) set @json2 = '{ "RequestId": "1", "ActionRecs": [ { "Type": "Submit", "Employee": "Joe" }, { "Type": "Review", "Employee": "Betty" }, { "Type": "Approve", "Employee": "Sam" }, { "Type": "Approve", "Employee": "Bill"

Reading json array into rows in SQL Server

南楼画角 提交于 2020-07-02 02:01:12
问题 Given the sample json data below, how can I write a query to pull the array data all in one step? My goal is to have one row for each item in the ActionRecs array (4). My actual json is more complicated but I think this gives a good example of my goal. declare @json2 nvarchar(max) set @json2 = '{ "RequestId": "1", "ActionRecs": [ { "Type": "Submit", "Employee": "Joe" }, { "Type": "Review", "Employee": "Betty" }, { "Type": "Approve", "Employee": "Sam" }, { "Type": "Approve", "Employee": "Bill"

Reading json array into rows in SQL Server

我只是一个虾纸丫 提交于 2020-07-02 02:00:45
问题 Given the sample json data below, how can I write a query to pull the array data all in one step? My goal is to have one row for each item in the ActionRecs array (4). My actual json is more complicated but I think this gives a good example of my goal. declare @json2 nvarchar(max) set @json2 = '{ "RequestId": "1", "ActionRecs": [ { "Type": "Submit", "Employee": "Joe" }, { "Type": "Review", "Employee": "Betty" }, { "Type": "Approve", "Employee": "Sam" }, { "Type": "Approve", "Employee": "Bill"

how to set ansible conditinal search

自作多情 提交于 2020-01-06 08:03:21
问题 I am trying to extract few values from a task out put. please see my playbook sample - name: Iterate JSON set_fact: app_item: "{{ item.name }}" when: "{{ result.results|json_query('[].\"scope member\"[?\"vdom\"==`\"vdom-shop\"`].vdom')|flatten|first }} == vdom-shop" with_items: "{{ result.results }}" please see the json output from the previous task { "msg": { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": false, "failed": false, "msg": "Custom Query

SQL Server - “for json path” statement does not return more than 2984 lines of JSON string

为君一笑 提交于 2020-01-01 19:24:15
问题 I'm trying to generate huge amount of data in a complex and nested JSON string using "for json path" statement, and I'm using multiple functions to create different parts of this JSON string, as follow: declare @queue nvarchar(max) select @queue = ( select x.ID as layoutID , l.Title as layoutName , JSON_QUERY(queue_objects (@productID, x.ID)) as [objects] from Layouts x inner join LayoutLanguages l on l.LayoutID = x.ID where x.ID = @layoutid group by x.ID, l.Title for json path ) select

C# Dapper using JSON_VALUE for SQL Server 2016

空扰寡人 提交于 2019-12-19 03:24:10
问题 I want to query data from my table using JSON_VALUE : var str = "123"; var value = "Name" using(var conn = GetMyConnection()) { var result = conn.QueryFirstOrDefault<string>( @"SELECT [Id] FROM [dbo].[MyTable] WHERE JSON_VALUE([JsonColumn], @MyQuery) = @Str", new { MyQuery = $"$.{value}", Str = str } ); } I try this in SQL Server, it is working: SELECT [Id] FROM [dbo].[MyTable] WHERE JSON_VALUE([JsonColumn], '$.Name') = '123' How should I adjust my code? 回答1: I try this in SQL Server, it

How to search SQL column containing JSON array

谁说胖子不能爱 提交于 2019-12-17 19:39:40
问题 I have a SQL column that has a single JSON array: {"names":["Joe","Fred","Sue"]} Given a search string, how can I use SQL to search for a match in the names array? I am using SQL 2016 and have looked at JSON_QUERY, but don't know how to search for a match on a JSON array. Something like below would be nice. SELECT * FROM table WHERE JSON_QUERY(column, '$.names') = 'Joe' 回答1: For doing a search in a JSON array, one needs to use OPENJSON DECLARE @table TABLE (Col NVARCHAR(MAX)) INSERT INTO

How to update a nested array in JSON in mssql

拥有回忆 提交于 2019-12-13 20:18:40
问题 I am using mssql and one column is having json data, I want to update that part of that json which is an array, by passing the id. { "customerName":"mohan", "custId":"e35273d0-c002-11e9-8188-a1525f580dfd", "feeds":[ { "feedId":"57f221d0-c310-11e9-8af7-cf1cf42fc72e", "feedName":"ccsdcdscsdc", "format":"Excel", "sources":[ { "sourceId":69042417, "name":"TV 2 Livsstil" }, { "sourceId":69042419, "name":"Turk Max" } ] }, { "feedId":"59bbd360-c312-11e9-8af7-cf1cf42fc72e", "feedName":