json_query problem

I am reading a cmdb for location information and then I’m trying to match on the room number in order to get the locations id. The matching data is coming from a csv file. The play works for rooms that have letters in them but not if it is just numbers. I have not been able to figure out how to make it work.
Result of cmdb lookup:

`
“building_rooms_result.json”: [
{
“buildingName”: “xxx Building”,
“city”: “Montreal”,
“commonName”: “”,
“country”: “Canada”,
“createdAt”: “2018-07-13T06:03:57.000Z”,
“fullName”: “Downtown/xxx Building/Floor 0005/5106”,
“id”: “ck2apr6yb002708380h9h7v3f”,
“loadedAt”: “2019-10-28T17:48:28.000Z”,
“locationKey”: “240|0005|5106”,
“locationType”: “Classroom”,
“name”: “5106”,
“parentId”: “ck2aps8cl0e260838rofis4v6”,
},

{
“buildingName”: “xxx Building”,
“city”: “Montreal”,
“commonName”: “”,
“country”: “Canada”,
“createdAt”: “2018-07-13T06:06:32.000Z”,
“fullName”: “Downtown/xxx Building/Floor 0004/4-TDUCT149”,
“id”: “ck2apr6zh009g0838abhya4sj”,
“loadedAt”: “2019-10-28T17:48:29.000Z”,
“locationKey”: “240|0004|4-TDUCT149”,
“locationType”: “Ducts”,
“name”: “4-TDUCT149”,
“parentId”: “ck2aps8br0diz08383bmk41yj”,
},

{
“buildingName”: “xxx Building”,
“city”: “Montreal”,
“commonName”: “”,
“country”: “Canada”,
“createdAt”: “2018-07-13T06:04:05.000Z”,
“fullName”: “Downtown/xxx Building/Floor 0001/1-STAIR4”,
“id”: “ck2apr6zq00bp0838h73fdrzf”,
“loadedAt”: “2019-10-28T17:48:31.000Z”,
“locationKey”: “240|0001|1-STAIR4”,
“locationType”: “Stairs”,
“name”: “1-STAIR4”,
“parentId”: “ck2aptbfr0tr9083813gkgava”,
}

]
`

This is the json_query I’m using. If I try to match on 1-STAIR4, it works. If I try to match on 5106 it does not match and I get the default na in the jacks_list.

`

  • name: create new list with all jack info
    set_fact:
    jacks_list: “{{ jacks_list | default() +
    [ { ‘number’: item.value.JACKNUMBER,
    ‘locationId’: building_rooms_result.json | json_query(query_locat) | default(‘na’, True),
    ‘telcoId’: telco_result.json.0.id
    }] }}”
    vars:
    query_locat: ‘[?name=={{ item.value.ROOMNUMBER | string }}].id | [0]’
    loop: “{{ connections.dict | dict2items }}”

`

`
The csv import data looks like:
ok: [127.0.0.1] => (item={‘key’: u’240D005082’, ‘value’: {u’ACTIVEDATE’: u’01-Dec-00’, u’SHUT’: u’0’, u’LASTNAME’: u’‘, u’VLAN’: u’71’, u’ROOMNUMBER’: u’5102’, u’ROOMID’: u’240D’, u’PORT_TYPE’: u’GigabitEthernet1/0/37’, u’ACTIVEBY’: u’‘, u’PORT_GROUP’: u’eng’, u’DEPTNAME’: u’Department of ‘, u’PORT_NO’: u’1/0/37’, u’FIRSTNAME’: u’S’, u’AUTHORIZEDBY’: u’So, Mr.‘, u’SPEED’: u’auto’, u’FOAPAL’: u’‘, u’DUPLEX’: u’auto’, u’DEPTCODE’: u’00156’, u’BUILDCODE’: u’000240’, u’SWITCHNAME’: u’xxx-5050-sw1’, u’JACKNUMBER’: u’240D005082’, u’F_ROOMCODE’: u’'}})

ok: [127.0.0.1] => (item={‘key’: u’240D005028’, ‘value’: {u’ACTIVEDATE’: u’01-Aug-19’, u’SHUT’: u’0’, u’LASTNAME’: u’IT’, u’VLAN’: u’67’, u’ROOMNUMBER’: u’5110’, u’ROOMID’: u’240D’, u’PORT_TYPE’: u’GigabitEthernet1/0/34’, u’ACTIVEBY’: u’mary’, u’PORT_GROUP’: u’eng’, u’DEPTNAME’: u’Department ‘, u’PORT_NO’: u’1/0/34’, u’FIRSTNAME’: u’ECE’, u’AUTHORIZEDBY’: u’, Mr.‘, u’SPEED’: u’auto’, u’FOAPAL’: u’000000’, u’DUPLEX’: u’auto’, u’DEPTCODE’: u’00156’, u’BUILDCODE’: u’000240’, u’SWITCHNAME’: u’xxxr-5050-sw1’, u’JACKNUMBER’: u’240D005028’, u’F_ROOMCODE’: u’5110’}})

ok: [127.0.0.1] => (item={‘key’: u’240D005280’, ‘value’: {u’ACTIVEDATE’: u’08-Nov-06’, u’SHUT’: u’0’, u’LASTNAME’: u’‘, u’VLAN’: u’820’, u’ROOMNUMBER’: u’5080HLWY’, u’ROOMID’: u’240D’, u’PORT_TYPE’: u’GigabitEthernet3/0/35’, u’ACTIVEBY’: u’csr3’, u’PORT_GROUP’: u’noc’, u’DEPTNAME’: u’Network’, u’PORT_NO’: u’3/0/35’, u’FIRSTNAME’: u’Wireless’, u’AUTHORIZEDBY’: u’NOR’, u’SPEED’: u’auto 10 100’, u’FOAPAL’: u’000000’, u’DUPLEX’: u’auto’, u’DEPTCODE’: u’00043’, u’BUILDCODE’: u’000240’, u’SWITCHNAME’: u’xxxr-5050-sw1’, u’JACKNUMBER’: u’240D005280’, u’F_ROOMCODE’: u’'}})

`

From the above only 5080HLWY will match to a record in locations. Looks like its an issue of string to int but I cant seem to figure out how and where to convert it. I am using the read_csv Ansible module to read the csv file.