I have the following json data:
[
{
"date_created": "2019-12-25 12:57:58",
"date_updated": "2020-12-18 16:18:29",
"description": "Scala is a multi-paradigm, general-purpose programming language.",
"discount_price": 2,
"id": 1,
"image_path": "",
"on_discount": false,
"price": 20,
"title": "The Art of Scala"
},
{
"date_created": "2019-03-16 05:15:39",
"date_updated": "2020-12-29 08:40:44",
"description": "Agile practices discover requirements and develop solutions through collaborative effort.",
"discount_price": 3,
"id": 2,
"image_path": "",
"on_discount": true,
"price": 30,
"title": "The Joy of Agile"
},
{
"date_created": "2020-09-13 14:40:39",
"date_updated": "2020-09-23 10:52:39",
"description": "Pages is a word processor developed by Apple Inc.",
"discount_price": 5,
"id": 3,
"image_path": "",
"on_discount": false,
"price": 50,
"title": "Talks About Pages"
},
{
"date_created": "2020-07-20 17:51:23",
"date_updated": "2020-08-04 12:06:58",
"description": "Microsoft Visual Studio is an integrated development environment (IDE) from Microsoft.",
"discount_price": 2,
"id": 4,
"image_path": "",
"on_discount": false,
"price": 20,
"title": "This Is A Course About Visual Studio"
},
{
"date_created": "2020-07-04 01:02:49",
"date_updated": "2021-01-31 15:07:20",
"description": "Scala is a multi-paradigm, general-purpose programming language.",
"discount_price": 3,
"id": 5,
"image_path": "",
"on_discount": true,
"price": 30,
"title": "Even A Kid Can Learn Scala!"
}]
I want to fetch a record using the key 'id' from the data. I did in the following way:
for i in data_id:#data_id is the json objects
if i['id']==id:
print(i)
How can I do this without linear scan. As if there is large amount of data, it takes huge amount of time for the last variable. So, I want the access time for all the variables to be same