I have list of values in an indexed DB table. I just want to convert into JSON array. My indexed DB table structure is given below.
I am using dexie framework for indexed DB .
db.booking.each(function(obj) {
var re_data = JSON.stringify(obj);
})
If I print re_data
it displays like this:
{
"booking_id": "18486",
"restbooking_id": "INBNGU18457",
"guest_id": 55648
},{
"booking_id": "18487",
"restbooking_id": "INBNGU18458",
"guest_id": 53726
},{
"booking_id": "18488",
"restbooking_id": "INBNGU18459",
"guest_id": 53537
}
My desired output need in JSON ARRAY like following ,
"bookings": [{
"booking_id": "18486",
"restbooking_id": "INBNGU18457",
"guest_id": 55648
},{
"booking_id": "18487",
"restbooking_id": "INBNGU18458",
"guest_id": 53726
},{
"booking_id": "18488",
"restbooking_id": "INBNGU18459",
"guest_id": 53537
}]
Or can I do this using the dexie framework itself?
I got the Answer : instead of db.booking.each() i used db.booking.toArray().
So Code is :
db.restaurantbooking.toArray(callfunc);
function callfunc(v)
{
console.log(JSON.stringify(v)); // This produce JSON Array.
}
My desired output is displayed.