Answer the question
In order to leave comments, you need to log in
How to check JSON for updates?
I get the JSON itself through requests and save it to a file, but I only need to save the new object inside the JSON and output it to the console.
{
"jsonrpc": "2.0",
"id": "fbad5793-e89e-45c4-9f3f-4b324bc82ba3",
"result": [
{
"id": "60831f62a40a2eb3973c9df3",
"account": [
{
"name": "transaction",
"title": "����� ����",
"value": "1315"
}
],
"air": "185784234",
"cancel_time": 0,
"cancelled_at": null,
"check_number": 1315,
"created_at": "2021-04-23T19:26:34.607Z",
"currency": 860,
"detail": null,
"error": null,
"is_adaptive": false,
"is_adaptive_batch": false,
"is_adaptive_chunk": false,
"is_corporate": false,
"is_refund": false,
"is_refundable": false,
"refund": null,
"refund_receipts": [],
"refunded_receipt": null,
"rrn": "111400433419",
"stan": "148864",
"state": 4,
"state_code": "paid",
"tid": "97006627",
"viewed": false
},
{
"id": "8da31f62a40a2eb3973c9df3",
"account": [
{
"name": "transaction",
"title": "����� ����",
"value": "1314"
}
],
"air": "185784234",
"cancel_time": 0,
"cancelled_at": null,
"check_number": 1314,
"created_at": "2021-04-23T19:26:34.607Z",
"currency": 860,
"detail": null,
"error": null,
"is_adaptive": false,
"is_adaptive_batch": false,
"is_adaptive_chunk": false,
"is_corporate": false,
"is_refund": false,
"is_refundable": false,
"refund": null,
"refund_receipts": [],
"refunded_receipt": null,
"rrn": "111400433419",
"stan": "148864",
"state": 4,
"state_code": "paid",
"tid": "97006627",
"viewed": false
}
]
}
Answer the question
In order to leave comments, you need to log in
upd: Each object and each request has an ID.
The ID of each object is greater than the previous one by 1.
It's not entirely clear what the actual question is? How to compare 2 received json results? Or how to make a request with an interval?
If the objects are unique by id, then you can get a list (set) of identifiers of one request and another, then find the differences in id and use them to display the desired results from the new request.
ids = {result['id'] for result in data['result']}
print(ids)
{'8da31f62a40a2eb3973c9df3', '60831f62a40a2eb3973c9df3'}
{'8da31f62a40a2eb3973c9df3', '60831f62a40a2eb3973c9df3', '60831f62a40a2eb3973c9df5'}
diff_ids = new_ids - ids
news = [result for result in new_data['result'] if result['id'] in diff_ids]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question