Enable key lookup after the key is found
Created by: rameshrvr
If the key is found we stoped the lookup inside value of that key.
sample_data = {
"build_version": {
"model_name": "MacBook Pro",
"build_version": {
"processor_name": "Intel Core i7",
"processor_speed": "2.7 GHz",
"core_details": {
"build_version": "4",
"l2_cache(per_core)": "256 KB"
}
},
"number_of_cores": "4",
"memory": "256 KB",
},
"os_details": {
"product_version": "10.13.6",
"build_version": "17G65"
},
"name": "Test",
"date": "YYYY-MM-DD HH:MM:SS"
}
For the above sample data, lookup for key build_version
should return
result = [
{
'build_version': {
'processor_name': 'Intel Core i7',
'processor_speed': '2.7 GHz',
'core_details': {
'build_version': '4',
'l2_cache(per_core)': '256 KB'
}
},
'memory': '256 KB',
'model_name': 'MacBook Pro',
'number_of_cores': '4'
},
{
'processor_name': 'Intel Core i7',
'processor_speed': '2.7 GHz',
'core_details': {
'build_version': '4',
'l2_cache(per_core)': '256 KB'
}
}, '4', '17G65'
]
But it is returning
result = [
{
'build_version': {
'processor_name': 'Intel Core i7',
'processor_speed': '2.7 GHz',
'core_details': {
'build_version': '4',
'l2_cache(per_core)': '256 KB'
}
},
'memory': '256 KB',
'model_name': 'MacBook Pro',
'number_of_cores': '4'
}, '17G65'
]