Home > Mobile >  Retrieving values from nested json using Python
Retrieving values from nested json using Python

Time:04-21

I have a json string below that i need to pull out all the values for securityId from _source. I expect the result to be NGN33 and NGG2 however the code below only returns NGN33.

How do i get the code to go through the data and retrieve all securityId values from _source?

import json
  
# JSON string

product = ' {"took":3,"timed_out":false,"_shards":{"total":5,"successful":5,"skipped":0,"failed":0},"hits":{"total":36450,"max_score":5.2289367,"hits":[{"_index":"securitylisting","_type":"securitylistingtype","_id":"1238346721692487680","_score":5.2289367,"_source":{"id":1238346721692487680,"assetType":"FUTURE","exchangeCode":"CME","securityCode":"NG","securityId":"NGG2","enabled":true,"createdTimestampUtc":"2022-03-09T02:11:19.898Z","updatedTimestampUtc":"2022-04-14T23:56:51.077Z","productType":"OUTRIGHT","currencyCode":"USD","description":"Henry Hub Natural Gas Futures","divisor":"3","tickSize":"1","tickValue":"10.0","expiry":"2032-02-28","lastTradingDate":"2032-01-28","isFractionalContract":"false","displayFactor":"0.001","exchangeId":"2224171651002540032","aliases":[{"securityIdSource":"TT","securityCode":"NG","securityId":"NGG32"},{"securityIdSource":"EXCHANGE","securityCode":"NG","securityId":"NGG2"}],"protobuf":"CICggLqEud XERABGgNDTUUiAk5HKgROR0cyShcaC3Byb2R1Y3RUeXBlIghPVVRSSUdIVEoTGgxj\r\ndXJyZW5jeUNvZGUiA1VTREosGgtkZXNjcmlwdGlvbiIdSGVucnkgSHViIE5hdHVyYWwgR2FzIEZ1\r\ndHVyZXNKDBoHZGl2aXNvciIBM0oNGgh0aWNrU2l6ZSIBMUoRGgl0aWNrVmFsdWUiBDEwLjBKFBoG\r\nZXhwaXJ5IgoyMDMyLTAyLTI4Sh0aD2xhc3RUcmFkaW5nRGF0ZSIKMjAzMi0wMS0yOEodGhRpc0Zy\r\nYWN0aW9uYWxDb250cmFjdCIFZmFsc2VKFhoNZGlzcGxheUZhY3RvciIFMC4wMDFKIRoKZXhjaGFu\r\nZ2VJZCITMjIyNDE3MTY1MTAwMjU0MDAzMlIPIgJUVCoCTkcyBU5HRzMyUhQiCEVYQ0hBTkdFKgJO\r\nRzIETkdHMg==\r\n"}},{"_index":"securitylisting","_type":"securitylistingtype","_id":"1230533848048078848","_score":5.2289367,"_source":{"id":1230533848048078848,"assetType":"FUTURE","exchangeCode":"CME","securityCode":"NG","securityId":"NGN33","enabled":true,"createdTimestampUtc":"2022-02-15T12:45:45.665Z","updatedTimestampUtc":"2022-04-17T05:48:29.958Z","productType":"OUTRIGHT","currencyCode":"USD","description":"Henry Hub Natural Gas Futures","divisor":"3","tickSize":"1","tickValue":"10.0","expiry":"2033-07-28","lastTradingDate":"2033-06-28","isFractionalContract":"false","displayFactor":"0.001","exchangeId":"2224171651002540032","aliases":[{"securityIdSource":"TT","securityCode":"NG","securityId":"NGN33"},{"securityIdSource":"EXCHANGE","securityCode":"NG","securityId":"NGN33"}],"protobuf":"CICggIi gO JERABGgNDTUUiAk5HKgVOR04zM0oXGgtwcm9kdWN0VHlwZSIIT1VUUklHSFRKExoM\r\nY3VycmVuY3lDb2RlIgNVU0RKLBoLZGVzY3JpcHRpb24iHUhlbnJ5IEh1YiBOYXR1cmFsIEdhcyBG\r\ndXR1cmVzSgwaB2Rpdmlzb3IiATNKDRoIdGlja1NpemUiATFKERoJdGlja1ZhbHVlIgQxMC4wShQa\r\nBmV4cGlyeSIKMjAzMy0wNy0yOEodGg9sYXN0VHJhZGluZ0RhdGUiCjIwMzMtMDYtMjhKHRoUaXNG\r\ncmFjdGlvbmFsQ29udHJhY3QiBWZhbHNlShYaDWRpc3BsYXlGYWN0b3IiBTAuMDAxSiEaCmV4Y2hh\r\nbmdlSWQiEzIyMjQxNzE2NTEwMDI1NDAwMzJSDyICVFQqAk5HMgVOR04zM1IVIghFWENIQU5HRSoC\r\nTkcyBU5HTjMz\r\n"}}]}} '
# Sanitize data
product = product.replace('\n', '').replace('\r', '')  

# Convert string to Python dict

product_dict = json.loads(str(product))


print (product_dict['hits']['hits'][1]['_source']['securityId'])

result - NGN33

expected result - NGN33 and NGG2

CodePudding user response:

Since product_dict['hits']['hits'][1]['_source']['securityId'] returns NGN33

Because product_dict['hits']['hits'] is a list and there are 2 different dicts in it 0,1 as you may have known by now.

so simply just do print (product_dict['hits']['hits'][0]['_source']['securityId'], product_dict['hits']['hits'][1]['_source']['securityId'])

Which will print NGG2 NGN33

CodePudding user response:

i have tested the below on a larger set of data and it does not return any results for securityId

print (product_dict['hits']['hits'][0]['_source']['securityId'], product_dict['hits']['hits'][1]['_source']['securityId'])

> import json
> 
> product =
> '{"took":3,"timed_out":false,"_shards":{"total":5,"successful":5,"skipped":0,"failed":0},"hits":{"total":36450,"max_score":5.2289367,"hits":[{"_index":"securitylisting","_type":"securitylistingtype","_id":"1238346721692487680","_score":5.2289367,"_source":{"id":1238346721692487680,"assetType":"FUTURE","exchangeCode":"CME","securityCode":"NG","securityId":"NGG2","enabled":true,"createdTimestampUtc":"2022-03-09T02:11:19.898Z","updatedTimestampUtc":"2022-04-14T23:56:51.077Z","productType":"OUTRIGHT","currencyCode":"USD","description":"Henry
> Hub Natural Gas
> Futures","divisor":"3","tickSize":"1","tickValue":"10.0","expiry":"2032-02-28","lastTradingDate":"2032-01-28","isFractionalContract":"false","displayFactor":"0.001","exchangeId":"2224171651002540032","aliases":[{"securityIdSource":"TT","securityCode":"NG","securityId":"NGG32"},{"securityIdSource":"EXCHANGE","securityCode":"NG","securityId":"NGG2"}],"protobuf":"CICggLqEud XERABGgNDTUUiAk5HKgROR0cyShcaC3Byb2R1Y3RUeXBlIghPVVRSSUdIVEoTGgxj\r\ndXJyZW5jeUNvZGUiA1VTREosGgtkZXNjcmlwdGlvbiIdSGVucnkgSHViIE5hdHVyYWwgR2FzIEZ1\r\ndHVyZXNKDBoHZGl2aXNvciIBM0oNGgh0aWNrU2l6ZSIBMUoRGgl0aWNrVmFsdWUiBDEwLjBKFBoG\r\nZXhwaXJ5IgoyMDMyLTAyLTI4Sh0aD2xhc3RUcmFkaW5nRGF0ZSIKMjAzMi0wMS0yOEodGhRpc0Zy\r\nYWN0aW9uYWxDb250cmFjdCIFZmFsc2VKFhoNZGlzcGxheUZhY3RvciIFMC4wMDFKIRoKZXhjaGFu\r\nZ2VJZCITMjIyNDE3MTY1MTAwMjU0MDAzMlIPIgJUVCoCTkcyBU5HRzMyUhQiCEVYQ0hBTkdFKgJO\r\nRzIETkdHMg==\r\n"}},{"_index":"securitylisting","_type":"securitylistingtype","_id":"1230533889064177664","_score":5.2289367,"_source":{"id":1230533889064177664,"assetType":"FUTURE","exchangeCode":"CME","securityCode":"NG","securityId":"NGN34","enabled":true,"createdTimestampUtc":"2022-02-15T12:45:55.444Z","updatedTimestampUtc":"2022-04-17T05:48:48.645Z","productType":"OUTRIGHT","currencyCode":"USD","description":"Henry
> Hub Natural Gas
> Futures","divisor":"3","tickSize":"1","tickValue":"10.0","expiry":"2034-07-28","lastTradingDate":"2034-06-28","isFractionalContract":"false","displayFactor":"0.001","exchangeId":"2224171651002540032","aliases":[{"securityIdSource":"TT","securityCode":"NG","securityId":"NGN34"},{"securityIdSource":"EXCHANGE","securityCode":"NG","securityId":"NGN34"}],"protobuf":"CICggO7Wge JERABGgNDTUUiAk5HKgVOR04zNEoXGgtwcm9kdWN0VHlwZSIIT1VUUklHSFRKExoM\r\nY3VycmVuY3lDb2RlIgNVU0RKLBoLZGVzY3JpcHRpb24iHUhlbnJ5IEh1YiBOYXR1cmFsIEdhcyBG\r\ndXR1cmVzSgwaB2Rpdmlzb3IiATNKDRoIdGlja1NpemUiATFKERoJdGlja1ZhbHVlIgQxMC4wShQa\r\nBmV4cGlyeSIKMjAzNC0wNy0yOEodGg9sYXN0VHJhZGluZ0RhdGUiCjIwMzQtMDYtMjhKHRoUaXNG\r\ncmFjdGlvbmFsQ29udHJhY3QiBWZhbHNlShYaDWRpc3BsYXlGYWN0b3IiBTAuMDAxSiEaCmV4Y2hh\r\nbmdlSWQiEzIyMjQxNzE2NTEwMDI1NDAwMzJSDyICVFQqAk5HMgVOR04zNFIVIghFWENIQU5HRSoC\r\nTkcyBU5HTjM0\r\n"}},{"_index":"securitylisting","_type":"securitylistingtype","_id":"1185544030478405632","_score":5.2289367,"_source":{"id":1185544030478405632,"assetType":"FUTURE","exchangeCode":"CME","securityCode":"NG","securityId":"NGH6","enabled":true,"createdTimestampUtc":"2021-10-14T09:12:17.286Z","updatedTimestampUtc":"2022-04-17T05:48:49.130Z","productType":"OUTRIGHT","currencyCode":"USD","description":"Henry
> Hub Natural Gas
> Futures","divisor":"3","tickSize":"1","tickValue":"10.0","expiry":"2026-03-25","lastTradingDate":"2026-02-25","isFractionalContract":"false","displayFactor":"0.001","exchangeId":"2224171651002540032","aliases":[{"securityIdSource":"TT","securityCode":"NG","securityId":"NGH26"},{"securityIdSource":"EXCHANGE","securityCode":"NG","securityId":"NGH6"}],"protobuf":"CICggJK7wPm5EBABGgNDTUUiAk5HKgROR0g2ShcaC3Byb2R1Y3RUeXBlIghPVVRSSUdIVEoTGgxj\r\ndXJyZW5jeUNvZGUiA1VTREosGgtkZXNjcmlwdGlvbiIdSGVucnkgSHViIE5hdHVyYWwgR2FzIEZ1\r\ndHVyZXNKDBoHZGl2aXNvciIBM0oNGgh0aWNrU2l6ZSIBMUoRGgl0aWNrVmFsdWUiBDEwLjBKFBoG\r\nZXhwaXJ5IgoyMDI2LTAzLTI1Sh0aD2xhc3RUcmFkaW5nRGF0ZSIKMjAyNi0wMi0yNUodGhRpc0Zy\r\nYWN0aW9uYWxDb250cmFjdCIFZmFsc2VKFhoNZGlzcGxheUZhY3RvciIFMC4wMDFKIRoKZXhjaGFu\r\nZ2VJZCITMjIyNDE3MTY1MTAwMjU0MDAzMlIPIgJUVCoCTkcyBU5HSDI2UhQiCEVYQ0hBTkdFKgJO\r\nRzIETkdINg==\r\n"}},{"_index":"securitylisting","_type":"securitylistingtype","_id":"1185544029807316993","_score":5.2289367,"_source":{"id":1185544029807316993,"assetType":"FUTURE","exchangeCode":"CME","securityCode":"NG","securityId":"NGV7","enabled":true,"createdTimestampUtc":"2021-10-14T09:12:17.126Z","updatedTimestampUtc":"2022-04-17T05:48:44.373Z","productType":"OUTRIGHT","currencyCode":"USD","description":"Henry
> Hub Natural Gas
> Futures","divisor":"3","tickSize":"1","tickValue":"10.0","expiry":"2027-10-28","lastTradingDate":"2027-09-28","isFractionalContract":"false","displayFactor":"0.001","exchangeId":"2224171651002540032","aliases":[{"securityIdSource":"TT","securityCode":"NG","securityId":"NGV27"},{"securityIdSource":"EXCHANGE","securityCode":"NG","securityId":"NGV7"}],"protobuf":"CIGggNK4wPm5EBABGgNDTUUiAk5HKgROR1Y3ShcaC3Byb2R1Y3RUeXBlIghPVVRSSUdIVEoTGgxj\r\ndXJyZW5jeUNvZGUiA1VTREosGgtkZXNjcmlwdGlvbiIdSGVucnkgSHViIE5hdHVyYWwgR2FzIEZ1\r\ndHVyZXNKDBoHZGl2aXNvciIBM0oNGgh0aWNrU2l6ZSIBMUoRGgl0aWNrVmFsdWUiBDEwLjBKFBoG\r\nZXhwaXJ5IgoyMDI3LTEwLTI4Sh0aD2xhc3RUcmFkaW5nRGF0ZSIKMjAyNy0wOS0yOEodGhRpc0Zy\r\nYWN0aW9uYWxDb250cmFjdCIFZmFsc2VKFhoNZGlzcGxheUZhY3RvciIFMC4wMDFKIRoKZXhjaGFu\r\nZ2VJZCITMjIyNDE3MTY1MTAwMjU0MDAzMlIPIgJUVCoCTkcyBU5HVjI3UhQiCEVYQ0hBTkdFKgJO\r\nRzIETkdWNw==\r\n"}},{"_index":"securitylisting","_type":"securitylistingtype","_id":"1153026101493108737","_score":5.2289367,"_source":{"id":1153026101493108737,"assetType":"FUTURE","exchangeCode":"CME","securityCode":"NG","securityId":"NGK4","enabled":true,"createdTimestampUtc":"2021-07-16T15:37:38.862Z","updatedTimestampUtc":"2022-04-17T05:48:44.852Z","productType":"OUTRIGHT","currencyCode":"USD","description":"Henry
> Hub Natural Gas
> Futures","divisor":"3","tickSize":"1","tickValue":"10.0","expiry":"2024-05-26","lastTradingDate":"2024-04-26","isFractionalContract":"false","displayFactor":"0.001","exchangeId":"2224171651002540032","aliases":[{"securityIdSource":"TT","securityCode":"NG","securityId":"NGK4"},{"securityIdSource":"EXCHANGE","securityCode":"NG","securityId":"NGK4"}],"protobuf":"CIGggOKV5JeAEBABGgNDTUUiAk5HKgROR0s0ShcaC3Byb2R1Y3RUeXBlIghPVVRSSUdIVEoTGgxj\r\ndXJyZW5jeUNvZGUiA1VTREosGgtkZXNjcmlwdGlvbiIdSGVucnkgSHViIE5hdHVyYWwgR2FzIEZ1\r\ndHVyZXNKDBoHZGl2aXNvciIBM0oNGgh0aWNrU2l6ZSIBMUoRGgl0aWNrVmFsdWUiBDEwLjBKFBoG\r\nZXhwaXJ5IgoyMDI0LTA1LTI2Sh0aD2xhc3RUcmFkaW5nRGF0ZSIKMjAyNC0wNC0yNkodGhRpc0Zy\r\nYWN0aW9uYWxDb250cmFjdCIFZmFsc2VKFhoNZGlzcGxheUZhY3RvciIFMC4wMDFKIRoKZXhjaGFu\r\nZ2VJZCITMjIyNDE3MTY1MTAwMjU0MDAzMlIOIgJUVCoCTkcyBE5HSzRSFCIIRVhDSEFOR0UqAk5H\r\nMgROR0s0\r\n"}},{"_index":"securitylisting","_type":"securitylistingtype","_id":"1185544029245280256","_score":5.2289367,"_source":{"id":1185544029245280256,"assetType":"FUTURE","exchangeCode":"CME","securityCode":"NG","securityId":"NGH1","enabled":true,"createdTimestampUtc":"2021-10-14T09:12:16.992Z","updatedTimestampUtc":"2022-04-17T05:48:39.077Z","productType":"OUTRIGHT","currencyCode":"USD","description":"Henry
> Hub Natural Gas
> Futures","divisor":"3","tickSize":"1","tickValue":"10.0","expiry":"2031-03-26","lastTradingDate":"2031-02-26","isFractionalContract":"false","displayFactor":"0.001","exchangeId":"2224171651002540032","aliases":[{"securityIdSource":"TT","securityCode":"NG","securityId":"NGH31"},{"securityIdSource":"EXCHANGE","securityCode":"NG","securityId":"NGH1"}],"protobuf":"CICggMa2wPm5EBABGgNDTUUiAk5HKgROR0gxShcaC3Byb2R1Y3RUeXBlIghPVVRSSUdIVEoTGgxj\r\ndXJyZW5jeUNvZGUiA1VTREosGgtkZXNjcmlwdGlvbiIdSGVucnkgSHViIE5hdHVyYWwgR2FzIEZ1\r\ndHVyZXNKDBoHZGl2aXNvciIBM0oNGgh0aWNrU2l6ZSIBMUoRGgl0aWNrVmFsdWUiBDEwLjBKFBoG\r\nZXhwaXJ5IgoyMDMxLTAzLTI2Sh0aD2xhc3RUcmFkaW5nRGF0ZSIKMjAzMS0wMi0yNkodGhRpc0Zy\r\nYWN0aW9uYWxDb250cmFjdCIFZmFsc2VKFhoNZGlzcGxheUZhY3RvciIFMC4wMDFKIRoKZXhjaGFu\r\nZ2VJZCITMjIyNDE3MTY1MTAwMjU0MDAzMlIPIgJUVCoCTkcyBU5HSDMxUhQiCEVYQ0hBTkdFKgJO\r\nRzIETkdIMQ==\r\n"}},{"_index":"securitylisting","_type":"securitylistingtype","_id":"1185544029245280257","_score":5.2289367,"_source":{"id":1185544029245280257,"assetType":"FUTURE","exchangeCode":"CME","securityCode":"NG","securityId":"NGU0","enabled":true,"createdTimestampUtc":"2021-10-14T09:12:16.992Z","updatedTimestampUtc":"2022-04-17T05:48:39.564Z","productType":"OUTRIGHT","currencyCode":"USD","description":"Henry
> Hub Natural Gas
> Futures","divisor":"3","tickSize":"1","tickValue":"10.0","expiry":"2030-09-28","lastTradingDate":"2030-08-28","isFractionalContract":"false","displayFactor":"0.001","exchangeId":"2224171651002540032","aliases":[{"securityIdSource":"TT","securityCode":"NG","securityId":"NGU30"},{"securityIdSource":"EXCHANGE","securityCode":"NG","securityId":"NGU0"}],"protobuf":"CIGggMa2wPm5EBABGgNDTUUiAk5HKgROR1UwShcaC3Byb2R1Y3RUeXBlIghPVVRSSUdIVEoTGgxj\r\ndXJyZW5jeUNvZGUiA1VTREosGgtkZXNjcmlwdGlvbiIdSGVucnkgSHViIE5hdHVyYWwgR2FzIEZ1\r\ndHVyZXNKDBoHZGl2aXNvciIBM0oNGgh0aWNrU2l6ZSIBMUoRGgl0aWNrVmFsdWUiBDEwLjBKFBoG\r\nZXhwaXJ5IgoyMDMwLTA5LTI4Sh0aD2xhc3RUcmFkaW5nRGF0ZSIKMjAzMC0wOC0yOEodGhRpc0Zy\r\nYWN0aW9uYWxDb250cmFjdCIFZmFsc2VKFhoNZGlzcGxheUZhY3RvciIFMC4wMDFKIRoKZXhjaGFu\r\nZ2VJZCITMjIyNDE3MTY1MTAwMjU0MDAzMlIPIgJUVCoCTkcyBU5HVTMwUhQiCEVYQ0hBTkdFKgJO\r\nRzIETkdVMA==\r\n"}},{"_index":"securitylisting","_type":"securitylistingtype","_id":"1230533848052273153","_score":5.2289367,"_source":{"id":1230533848052273153,"assetType":"FUTURE","exchangeCode":"CME","securityCode":"NG","securityId":"NGF33","enabled":true,"createdTimestampUtc":"2022-02-15T12:45:45.666Z","updatedTimestampUtc":"2022-04-17T05:48:30.908Z","productType":"OUTRIGHT","currencyCode":"USD","description":"Henry
> Hub Natural Gas
> Futures","divisor":"3","tickSize":"1","tickValue":"10.0","expiry":"2033-01-29","lastTradingDate":"2032-12-29","isFractionalContract":"false","displayFactor":"0.001","exchangeId":"2224171651002540032","aliases":[{"securityIdSource":"TT","securityCode":"NG","securityId":"NGF33"},{"securityIdSource":"EXCHANGE","securityCode":"NG","securityId":"NGF33"}],"protobuf":"CIGggIq gO JERABGgNDTUUiAk5HKgVOR0YzM0oXGgtwcm9kdWN0VHlwZSIIT1VUUklHSFRKExoM\r\nY3VycmVuY3lDb2RlIgNVU0RKLBoLZGVzY3JpcHRpb24iHUhlbnJ5IEh1YiBOYXR1cmFsIEdhcyBG\r\ndXR1cmVzSgwaB2Rpdmlzb3IiATNKDRoIdGlja1NpemUiATFKERoJdGlja1ZhbHVlIgQxMC4wShQa\r\nBmV4cGlyeSIKMjAzMy0wMS0yOUodGg9sYXN0VHJhZGluZ0RhdGUiCjIwMzItMTItMjlKHRoUaXNG\r\ncmFjdGlvbmFsQ29udHJhY3QiBWZhbHNlShYaDWRpc3BsYXlGYWN0b3IiBTAuMDAxSiEaCmV4Y2hh\r\nbmdlSWQiEzIyMjQxNzE2NTEwMDI1NDAwMzJSDyICVFQqAk5HMgVOR0YzM1IVIghFWENIQU5HRSoC\r\nTkcyBU5HRjMz\r\n"}},{"_index":"securitylisting","_type":"securitylistingtype","_id":"1230533848043884545","_score":5.2289367,"_source":{"id":1230533848043884545,"assetType":"FUTURE","exchangeCode":"CME","securityCode":"NG","securityId":"NGZ33","enabled":true,"createdTimestampUtc":"2022-02-15T12:45:45.664Z","updatedTimestampUtc":"2022-04-17T05:48:29.489Z","productType":"OUTRIGHT","currencyCode":"USD","description":"Henry
> Hub Natural Gas
> Futures","divisor":"3","tickSize":"1","tickValue":"10.0","expiry":"2033-12-28","lastTradingDate":"2033-11-28","isFractionalContract":"false","displayFactor":"0.001","exchangeId":"2224171651002540032","aliases":[{"securityIdSource":"TT","securityCode":"NG","securityId":"NGZ33"},{"securityIdSource":"EXCHANGE","securityCode":"NG","securityId":"NGZ33"}],"protobuf":"CIGggIa gO JERABGgNDTUUiAk5HKgVOR1ozM0oXGgtwcm9kdWN0VHlwZSIIT1VUUklHSFRKExoM\r\nY3VycmVuY3lDb2RlIgNVU0RKLBoLZGVzY3JpcHRpb24iHUhlbnJ5IEh1YiBOYXR1cmFsIEdhcyBG\r\ndXR1cmVzSgwaB2Rpdmlzb3IiATNKDRoIdGlja1NpemUiATFKERoJdGlja1ZhbHVlIgQxMC4wShQa\r\nBmV4cGlyeSIKMjAzMy0xMi0yOEodGg9sYXN0VHJhZGluZ0RhdGUiCjIwMzMtMTEtMjhKHRoUaXNG\r\ncmFjdGlvbmFsQ29udHJhY3QiBWZhbHNlShYaDWRpc3BsYXlGYWN0b3IiBTAuMDAxSiEaCmV4Y2hh\r\nbmdlSWQiEzIyMjQxNzE2NTEwMDI1NDAwMzJSDyICVFQqAk5HMgVOR1ozM1IVIghFWENIQU5HRSoC\r\nTkcyBU5HWjMz\r\n"}},{"_index":"securitylisting","_type":"securitylistingtype","_id":"1230533848048078848","_score":5.2289367,"_source":{"id":1230533848048078848,"assetType":"FUTURE","exchangeCode":"CME","securityCode":"NG","securityId":"NGN33","enabled":true,"createdTimestampUtc":"2022-02-15T12:45:45.665Z","updatedTimestampUtc":"2022-04-17T05:48:29.958Z","productType":"OUTRIGHT","currencyCode":"USD","description":"Henry
> Hub Natural Gas
> Futures","divisor":"3","tickSize":"1","tickValue":"10.0","expiry":"2033-07-28","lastTradingDate":"2033-06-28","isFractionalContract":"false","displayFactor":"0.001","exchangeId":"2224171651002540032","aliases":[{"securityIdSource":"TT","securityCode":"NG","securityId":"NGN33"},{"securityIdSource":"EXCHANGE","securityCode":"NG","securityId":"NGN33"}],"protobuf":"CICggIi gO JERABGgNDTUUiAk5HKgVOR04zM0oXGgtwcm9kdWN0VHlwZSIIT1VUUklHSFRKExoM\r\nY3VycmVuY3lDb2RlIgNVU0RKLBoLZGVzY3JpcHRpb24iHUhlbnJ5IEh1YiBOYXR1cmFsIEdhcyBG\r\ndXR1cmVzSgwaB2Rpdmlzb3IiATNKDRoIdGlja1NpemUiATFKERoJdGlja1ZhbHVlIgQxMC4wShQa\r\nBmV4cGlyeSIKMjAzMy0wNy0yOEodGg9sYXN0VHJhZGluZ0RhdGUiCjIwMzMtMDYtMjhKHRoUaXNG\r\ncmFjdGlvbmFsQ29udHJhY3QiBWZhbHNlShYaDWRpc3BsYXlGYWN0b3IiBTAuMDAxSiEaCmV4Y2hh\r\nbmdlSWQiEzIyMjQxNzE2NTEwMDI1NDAwMzJSDyICVFQqAk5HMgVOR04zM1IVIghFWENIQU5HRSoC\r\nTkcyBU5HTjMz\r\n"}}]}}
> '

i guess i need a loop to recursively check the nested json data?

  • Related