1👍
This is how to get it in python:
data = [
{
"id": 1,
"value": 123,
"value2": 123123
},
{
"id": 2,
"value": 1,
"value2": 214
}
]
result = None
for item in data:
if item['value'] == 123:
result = [item]
break
print(result)
0👍
Here is a javascript code to do this :-
function test()
{
//alert("Hi");
var text = '[{"id":1,"value":123,"value2":123123},{"id":2,"value":1,"value2":214}]'
json = JSON.parse(text);
var result = [];
for(var i = 0; i < json.length; i++) {
var obj = json[i];
if(obj['value'] == 123){
result.push(obj);
}
}
console.log(result);
}
- Django: select data from 2 models
- Most efficient / proper way to give Json response in Django?
- Attribute error 'LoginForm' object has no attribute 'cleaned_data' where login is carried out by mail and password
- Django Create Account ends in 550
- Is there an easier way to either create or re-write exist object? django
0👍
In views.py , you can get the value of the URL through request object
data = [
{
"id": 1,
"value": 123,
"value2": 123123
},
{
"id": 2,
"value": 1,
"value2": 214
}
]
print [ item for item in data if item['value'] == request.GET.get('value') ]
- Database design for online food delivery system with book a table
- How to create nested form in django?
Source:stackexchange.com