Not able to get opening hours from Google Place Details API - google-maps

I am trying to get opening_hours after getting the place IDs of many stores from the Google place details API. I do not get any opening hours in the response while all of these places do show opening hours when I google them directly. For eg. this is Safeway, 1071 El Camino Real, Redwood City, CA 94063, United States.
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJcY3Ya62jj4ARtl86jFsjUYE&fields=opening_hours&key=*******************
{
"html_attributions" : [],
"result" : {},
"status" : "OK"
}

It looks like place id ChIJcY3Ya62jj4ARtl86jFsjUYE is of type subpremise, not establishment, so that's why you're not getting its opening_hours (as there are none). The place id of the establishment appears to be ChIJpwPigbKjj4ARC4XRyMdMzJ8.
Try this:
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJpwPigbKjj4ARC4XRyMdMzJ8&fields=opening_hours&key=YOUR_API_KEY
Output:
{
"html_attributions" : [],
"result" : {
"opening_hours" : {
"open_now" : false,
"periods" : [
{
"close" : {
"day" : 0,
"time" : "2200"
},
"open" : {
"day" : 0,
"time" : "0600"
}
},
{
"close" : {
"day" : 1,
"time" : "2200"
},
"open" : {
"day" : 1,
"time" : "0600"
}
},
{
"close" : {
"day" : 2,
"time" : "2200"
},
"open" : {
"day" : 2,
"time" : "0600"
}
},
{
"close" : {
"day" : 3,
"time" : "2200"
},
"open" : {
"day" : 3,
"time" : "0600"
}
},
{
"close" : {
"day" : 4,
"time" : "2200"
},
"open" : {
"day" : 4,
"time" : "0600"
}
},
{
"close" : {
"day" : 5,
"time" : "2200"
},
"open" : {
"day" : 5,
"time" : "0600"
}
},
{
"close" : {
"day" : 6,
"time" : "2200"
},
"open" : {
"day" : 6,
"time" : "0600"
}
}
],
"weekday_text" : [
"Monday: 6:00 AM – 10:00 PM",
"Tuesday: 6:00 AM – 10:00 PM",
"Wednesday: 6:00 AM – 10:00 PM",
"Thursday: 6:00 AM – 10:00 PM",
"Friday: 6:00 AM – 10:00 PM",
"Saturday: 6:00 AM – 10:00 PM",
"Sunday: 6:00 AM – 10:00 PM"
]
}
},
"status" : "OK"
}
Hope this helps!

Related

I am trying to access room_type_info from json data but unable to do in swift [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
JSON:
"results" : [ {
"property_code" : "WYBOSCHH",
"property_name" : "Wyndham Boston Chelsea",
"location" : {
"latitude" : 42.39795,
"longitude" : -71.03977
},
"address" : {
"line1" : "201 Everett Avenue",
"city" : "Chelsea",
"region" : "MA",
"postal_code" : "02150-1816",
"country" : "US"
},
"total_price" : {
"amount" : "287.30",
"currency" : "USD"
},
"min_daily_rate" : {
"amount" : "71.82",
"currency" : "USD"
},
"contacts" : [ {
"type" : "PHONE",
"detail" : "1-617-8842900"
}, {
"type" : "FAX",
"detail" : "1-617-8847888"
} ],
"amenities" : [ {
"amenity" : "ICE_MACHINE",
"ota_code" : 52,
"description" : "Ice machine"
}, {
"amenity" : "RESTAURANT",
"ota_code" : 76,
"description" : "Restaurant"
}, {
"amenity" : "BABY_SITTING",
"ota_code" : 8,
"description" : "Baby sitting"
}, {
"amenity" : "BEAUTY_SALON",
"ota_code" : 107,
"description" : "Beauty shop/salon"
}, {
"amenity" : "ELEVATORS",
"ota_code" : 33,
"description" : "Elevators"
}, {
"amenity" : "INTERNET_PUBLIC_AREAS",
"ota_code" : 178,
"description" : "Internet access in public areas"
}, {
"amenity" : "JACUZZI",
"ota_code" : 55,
"description" : "Jacuzzi"
}, {
"amenity" : "LAUNDRY_SERVICE",
"ota_code" : 58,
"description" : "Laundry/Valet service"
}, {
"amenity" : "PARKING",
"ota_code" : 68,
"description" : "Parking"
}, {
"amenity" : "LOUNGE_BARS",
"ota_code" : 165,
"description" : "Lounges/bars"
}, {
"amenity" : "POOL",
"ota_code" : 71,
"description" : "Pool"
}, {
"amenity" : "OUTDOOR_POOL",
"ota_code" : 66,
"description" : "Outdoor pool"
} ],
"awards" : [ {
"provider" : "Local Star Rating",
"rating" : "3"
}, {
"provider" : "AAA",
"rating" : "3"
} ],
"images" : [ {
"category" : "MAIN_IMAGE",
"width" : 70,
"height" : 70,
"url" : "http://multimediarepository.amadeus.com/cmr/retrieve/hotel/5811669CC5364943965EC9FB3D56642C/A"
}, {
"category" : "MAIN_IMAGE",
"width" : 480,
"height" : 260,
"url" : "http://multimediarepository.amadeus.com/cmr/retrieve/hotel/5811669CC5364943965EC9FB3D56642C/J"
} ],
"rooms" : [ {
"booking_code" : "N2DA01",
"room_type_code" : "N2D",
"rate_plan_code" : "A01",
"total_amount" : {
"amount" : "287.30",
"currency" : "USD"
},
"rates" : [ {
"start_date" : "2016-03-14",
"end_date" : "2016-03-16",
"currency_code" : "USD",
"price" : 143.65
} ],
"descriptions" : [ "PAY NOW GET 200 BONUS POINTS", "2 DOUBLE BED ROOM, WIFI, 32 INCH FLAT SCREEN", "TV." ],
"room_type_info" : {
"room_type" : "Non-smoking",
"bed_type" : "Double",
"number_of_beds" : "2"
},
"rate_type_code" : "A01"
} ],
"_links" : {
"more_rooms_at_this_hotel" : {
"href" : "http://api.sandbox.amadeus.com/v1.2/hotels/WYBOSCHH?apikey=zO8hvuhC5ejQBwJgMcGzS19fGpExrRuQ&check_in=2016-03-14&check_out=2016-03-16"
}
}
}, {
"property_code" : "HYBOSHHS",
"property_name" : "Hyatt Regency Boston Harbor",
"location" : {
"latitude" : 42.35914,
"longitude" : -71.02742
},
"address" : {
"line1" : "101 Harborside Dr",
"city" : "Boston",
"region" : "MA",
"postal_code" : "02128",
"country" : "US"
},
"total_price" : {
"amount" : "297.44",
"currency" : "USD"
},
"min_daily_rate" : {
"amount" : "139.92",
"currency" : "USD"
},
"contacts" : [ {
"type" : "PHONE",
"detail" : "1-617-568-1234"
}, {
"type" : "FAX",
"detail" : "1-617-567-8856"
} ],
"amenities" : [ {
"amenity" : "COFFEE_SHOP",
"ota_code" : 20,
"description" : "Coffee shop"
}, {
"amenity" : "RESTAURANT",
"ota_code" : 76,
"description" : "Restaurant"
}, {
"amenity" : "ACCESSIBLE_FACILITIES",
"ota_code" : 47,
"description" : "Accessible facilities"
}, {
"amenity" : "BABY_SITTING",
"ota_code" : 8,
"description" : "Baby sitting"
}, {
"amenity" : "CAR_RENTAL",
"ota_code" : 15,
"description" : "Car rental desk"
}, {
"amenity" : "CHILDREN_WELCOME",
"ota_code" : 218,
"description" : "Children welcome"
}, {
"amenity" : "ELEVATORS",
"ota_code" : 33,
"description" : "Elevators"
}, {
"amenity" : "CURRENCY_EXCHANGE",
"ota_code" : 26,
"description" : "Currency exchange"
}, {
"amenity" : "GIFT_SHOP",
"ota_code" : 45,
"description" : "Gift/News stand"
}, {
"amenity" : "FREE_HIGH_SPEED_INTERNET",
"ota_code" : 222,
"description" : "Free high speed internet connection"
}, {
"amenity" : "INTERNET_PUBLIC_AREAS",
"ota_code" : 178,
"description" : "Internet access in public areas"
}, {
"amenity" : "PARKING",
"ota_code" : 68,
"description" : "Parking"
}, {
"amenity" : "PETS_ALLOWED",
"ota_code" : 224,
"description" : "Pets allowed"
}, {
"amenity" : "VALET_PARKING",
"ota_code" : 97,
"description" : "Valet parking "
}, {
"amenity" : "LOUNGE_BARS",
"ota_code" : 165,
"description" : "Lounges/bars"
}, {
"amenity" : "LOUNGE_BARS",
"ota_code" : 165,
"description" : "Lounges/bars"
}, {
"amenity" : "ROOM_SERVICE",
"ota_code" : 77,
"description" : "Room service"
}, {
"amenity" : "SAFE_DEPOSIT_BOX",
"ota_code" : 78,
"description" : "Safe deposit box"
}, {
"amenity" : "BALLROOM",
"ota_code" : 191,
"description" : "Ballroom"
} ],
"awards" : [ ],
"images" : [ {
"category" : "MAIN_IMAGE",
"width" : 70,
"height" : 70,
"url" : "http://multimediarepository.amadeus.com/cmr/retrieve/hotel/AE3C4B469985434AB8E48B23FD4A50CD/A"
}, {
"category" : "MAIN_IMAGE",
"width" : 320,
"height" : 480,
"url" : "http://multimediarepository.amadeus.com/cmr/retrieve/hotel/AE3C4B469985434AB8E48B23FD4A50CD/J"
} ],
"rooms" : [ {
"booking_code" : "KNGADPR",
"room_type_code" : "A1K",
"rate_plan_code" : "***",
"total_amount" : {
"amount" : "297.44",
"currency" : "USD"
},
"rates" : [ {
"start_date" : "2016-03-14",
"end_date" : "2016-03-15",
"currency_code" : "USD",
"price" : 139.92
}, {
"start_date" : "2016-03-15",
"end_date" : "2016-03-16",
"currency_code" : "USD",
"price" : 157.52
} ],
"descriptions" : [ "ADV PURCHASE* AVIATION KING", "1 KING BED: COFFEE MAKER:DATAPORT:" ],
"room_type_info" : {
"room_type" : "Room with bath - Superior",
"bed_type" : "King",
"number_of_beds" : "1"
},
"rate_type_code" : "***"
} ],
"_links" : {
"more_rooms_at_this_hotel" : {
"href" : "http://api.sandbox.amadeus.com/v1.2/hotels/HYBOSHHS?apikey=zO8hvuhC5ejQBwJgMcGzS19fGpExrRuQ&check_in=2016-03-14&check_out=2016-03-16"
}
}
} ]
}
Code:
var request = URLRequest(url: URL(string: url)!)
request.httpMethod = "GET"
let configuration = URLSessionConfiguration.default
let session = URLSession(configuration: configuration, delegate: nil, delegateQueue: OperationQueue.main)
let task = session.dataTask(with: request){(data, response, error) in
if (error != nil) {
print("Error")
}
else {
do {
let fetchedData = try JSONSerialization.jsonObject(with: data!, options: .mutableLeaves) as! NSDictionary
let results = fetchedData["results"]! as! NSArray
for eachFetchedHotel in results {
let eachHotel = eachFetchedHotel as! [String: Any]
let hotel_name = eachHotel["property_name"] as! String
for eachRoomInfo in eachHotel["rooms"] {
// if let roomTypeInfo = eachRoomInfo["room_type_info"] as! Int{
// let occupancy_type = roomTypeInfo["number_of_beds"] as! Int
// }
for item in eachRoomInfo["room_type_info"]{
let occupancy_type = item["number_of_beds"]
}
}
// let occupanct_type = eachHotel["rooms"]["room_type_info"]["number_of_beds"] as! Int
let price = eachHotel["total_price.currency" + "total_price.amount"] as! Int
let image = eachHotel["images.url"] as! NSData
self.fetchedHotelData.append(Room(name: hotel_name, occupancy: occupancy_type, price: price, vacant_status: true, image: image))
}
print(self.fetchedHotelData)
}
catch{
print("Error 2")
}
}
}
I recommend you using Alamofire (a powerful networking framework) and SwiftyJSON (for parsing JSON), they are very popular for iOS development.
With SwiftyJSON, you do not need to handle the error or worry about nested JSON, just do something like:
json["data"]["room_type_infor"].stringValue.

Google distance martix order by distance

When I fetchdata from https://maps.googleapis.com/maps/api/distancematrix/json?origins=10010&destinations=10011|10012|10013&key=AIzaSyBOsjeskUwOLYQZntsv7_34gVZ3xgcXko0
it returns :
{
"destination_addresses" : [
"New York, NY 10011, USA",
"New York, NY 10012, USA",
"New York, NY 10013, USA"
],
"origin_addresses" : [ "New York, NY 10010, USA" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "3.4 km",
"value" : 3389
},
"duration" : {
"text" : "19 mins",
"value" : 1156
},
"status" : "OK"
},
{
"distance" : {
"text" : "2.6 km",
"value" : 2632
},
"duration" : {
"text" : "13 mins",
"value" : 767
},
"status" : "OK"
},
{
"distance" : {
"text" : "9.5 km",
"value" : 9545
},
"duration" : {
"text" : "19 mins",
"value" : 1143
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
But I need data order by distance. First showing small then large.
Is it possible?
Sure!
1. Parse the JSON data to an object (JSON.parse);
2. Sort the elements array using code as below:
// given els is one of the elements extracted from this object:
let sorted = els.sort((a, b) => a.distance.value - b.distance.value);

Same request to Google Maps API works differently on various machines

I registered API key, and compossed the following url with it:
https://maps.googleapis.com/maps/api/distancematrix/json?units=metric&origins=Belarus,Minsk,Kuprevicha,1/2&destinations=Belarus,Minsk,Kurchatova,8&key=AIzaSyBngdHtfv-gbJkhKbsgJMqU5T-BnacZuPI
I am getting responce where street information were erased:
{
"destination_addresses" : [ "Minsk, Belarus" ],
"origin_addresses" : [ "Minsk, Belarus" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "1 m",
"value" : 0
},
"duration" : {
"text" : "1 min",
"value" : 0
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
My colleague sitting next to me firing same request recieves a correct full responce.
{
"destination_addresses" : [ "ул. Курчатова 8, Минск, Беларусь" ],
"origin_addresses" : [
"ул. Академика Купревича 1/2, Минск 220141, Беларусь"
],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "24,5 км",
"value" : 24526
},
"duration" : {
"text" : "20 мин.",
"value" : 1196
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
What is the reason of this weird behavior?

how to convert datetime from epoc to utc in mongodb

Hi all I have a collection name test_data and in this collect I have data like in given formate
Data = [{
"_id" : "53fe7ae0ef038fee879263d5",
"chanal_id" : "can1",
"instrumentnam" : "New Demo Device",
"siteid" : "53fe741d66455060e003c2d8",
"locationid" : "53fe74a866455060e003c2db",
"timestamp" : 1406916000,
"status" : "online",
"msgtype" : "demographics",
"fps" : "5",
"people" : [
{
"id" : 1,
"age" : 23,
"gender" : "male",
"ethnicity" : null,
"mood" : "happy",
"ethnicity_mod" : "White",
"mood_mod" : "Happy",
"gender_mod" : "Female",
"age_mod" : 22
}
],
"dateUTC" : 1409190000
},
{
"_id" : "53fe7ae0ef038fee879263d6",
"chanel_id" : "can1",
"instrumentnam" : "New Demo Device",
"siteid" : "53fe741d66455060e003c2d8",
"locationid" : "53fe74a866455060e003c2db",
"timestamp" : 1406917800,
"status" : "online",
"msgtype" : "demographics",
"fps" : "5",
"people" : [
{
"id" : 2,
"age" : 16,
"gender" : "female",
"ethnicity" : null,
"mood" : "happy",
"ethnicity_mod" : "White",
"mood_mod" : "Happy"
}
],
"dateUTC" : 1409186528
},
{
"_id" : "53fe7ae0ef038fee879263d7",
"chanal_id" : "can1",
"instrumentnam" : "New Demo Device",
"siteid" : "53fe741d66455060e003c2d8",
"locationid" : "53fe74a866455060e003c2db",
"timestamp" : 1406918800,
"status" : "online",
"msgtype" : "demographics",
"fps" : "5",
"people" : [
{
"id" : 3,
"age" : 33,
"gender" : "male",
"ethnicity" : null,
"mood" : "happy",
"ethnicity_mod" : "White"
}
],
"dateUTC" : 1409186528
}
,
{
"_id" : "53fe7ae0ef038fee879263d8",
"chanal_id" : "can1",
"instrumentnam" : "New Demo Device",
"siteid" : "53fe741d66455060e003c2d8",
"locationid" : "53fe74a866455060e003c2db",
"timestamp" : 1406919800,
"status" : "online",
"msgtype" : "demographics",
"fps" : "5",
"people" : [
{
"id" : 4,
"age" : 45,
"gender" : "female",
"ethnicity" : null,
"mood" : "happy",
"age_mod" : 5
}
],
"dateUTC" : 1409186528
},
{
"_id" : "53fe7ae0ef038fee879263d9",
"chanal_id" : "can1",
"instrumentnam" : "New Demo Device",
"siteid" : "53fe741d66455060e003c2d8",
"locationid" : "53fe74a866455060e003c2db",
"timestamp" : 1406920800,
"status" : "online",
"msgtype" : "demographics",
"fps" : "5",
"people" : [
{
"id" : 5,
"age" : 14,
"gender" : "female",
"ethnicity" : null,
"mood" : "angry"
}
],
"dateUTC" : 1409186528
},
{
"_id" :"53ff927266455060e003c2e0",
"chanal_id" : "rtsp://192.168.1.83:554/live.sdp",
"instrumentnam" : "Test Device",
"siteid" : "53f62abf66455068373665ff",
"locationid" : "53f62bb86645506837366603",
"timestamp" : 1409258116,
"status" : "online",
"msgtype" : "demographics",
"fps" : "32",
"people" : [],
"dateUTC" : 1409258098
}]
which is in json format,
What I am trying to do
1. I want to convert timestamp from epoc time to utc time in linux system. and
2. I want to convert this json data to csv format using mongodb code in linux system.
So can anyone please help me out to do this.

How to unwind single document and then process into single result in an array

I have had some great help from #Joao and #Blakes Seven in order to get me as far as I've got. Awesome, thanks guys very much.
What I have a problem with is going from my original simple example and applying it to my real life scenario.
Where I've got to is two separate scripts which work perfectly by themselves but when I try to being the two together, it then only does the first part without applying the second part; it's my lack of experience in Mongo letting me down here.
So, I am able to get a name value pair from the first array set within a document using the following code:
db.raw_originBusinessData.aggregate([
{ "$match": {objectOriginAPI : "Profit & Loss"}}
,{ "$unwind": "$objectRawOriginData.Reports" }
,{ "$unwind": "$objectRawOriginData.Reports.Rows" }
,{ "$unwind": "$objectRawOriginData.Reports.Rows.Rows" }
,{ "$group": {"_id": "$_id","first": { "$first": "$objectRawOriginData.Reports.Rows.Rows.Cells.Value" }
, "temp": { "$push": "$objectRawOriginData.Reports.Rows.Rows.Cells.Value" }
}},
{ "$unwind": "$temp" }
,{"$skip":1}
,{ "$group": {"_id": "$_id", "AccountBalance":{ "$first": "$first" }
}}
])
This gives me the result below, which I'm happy with except for the fact I am not able to name the two values in the Account Balances array.
Mission 1: I want AccountBalance to be an array and the first position has two values: "AccountName" : "Sales", "AccountValue" : 5428.04.
{
"result" : [
{
"_id" : ObjectId("564d12da1506995581569428"),
"AccountBalance" : [
"Sales",
"5428.64"
]
}
],
"ok" : 1.0000000000000000
}
The second part of the problem is that it is only processing one set of values whereas, the document I am processing on has 9 sets to do. I have run the following $unwind on the document and it has perfectly split them into 9 results:
db.raw_originBusinessData.aggregate([
// find document
{ "$match": {objectOriginAPI : "Profit & Loss"}}
// unwind into multiple documents
,{ "$unwind": "$objectRawOriginData.Reports" }
,{ "$unwind": "$objectRawOriginData.Reports.Rows" }
,{ "$unwind": "$objectRawOriginData.Reports.Rows.Rows" }
])
So I get 9 results perfect. Mission 2: What I want to do is to combine this with the script I showed above. I tried the following but it does absolutely no more than the script just above.
db.raw_originBusinessData.aggregate([
// find document
{ "$match": {objectOriginAPI : "Profit & Loss"}}
// unwind into multiple documents
,{ "$unwind": "$objectRawOriginData.Reports" }
,{ "$unwind": "$objectRawOriginData.Reports.Rows" }
,{ "$unwind": "$objectRawOriginData.Reports.Rows.Rows" }
]
// process each document
,{ "$unwind": "$objectRawOriginData.Reports" }
, {"$unwind": "$objectRawOriginData.Reports.Rows" }
, {"$unwind": "$objectRawOriginData.Reports.Rows.Rows" }
, {"$group": {"_id": "$_id","first": { "$first": "$objectRawOriginData.Reports.Rows.Rows.Cells.Value" }
, "a": { "$push": "$objectRawOriginData.Reports.Rows.Rows.Cells.Value" }
}},
{ "$unwind": "$a" }
,{"$skip":1}
,{ "$group": {"_id": "$_id", "AccountBalance":{ "$first": "$first" }
}}
)
Desired Outcome
What I want to get is the following. This is combination of mission 1 and 2.
{
"result" : [
{
"_id" : ObjectId("564d12da1506995581569428"),
"AccountBalance" : [
{"AccountName" : "Sales",
"AccountValue" : "5428.64"},
{"AccountName" : "Total Income",
"AccountValue" : "5428.64"},
{"AccountName" : "Cost of Sales",
"AccountValue" : "100.00"},
{"AccountName" : "Total Cost of Sales",
"AccountValue" : "100.00"},
{"AccountName" : "Gross Profit",
"AccountValue" : "5328.64"},
{"AccountName" : "Advertising",
"AccountValue" : "100.00"},
{"AccountName" : "General Expenses",
"AccountValue" : "100.00"},
{"AccountName" : "Total Operating Expenses",
"AccountValue" : "200.00"},
{"AccountName" : "Net Profit",
"AccountValue" : "5128.64"}
]
}
],
"ok" : 1.0000000000000000
}
The document that I am using as a source is from Xero API - it's one of their reports. It has the same pattern as most reports exported in JSON like Oracle. Below is the actual report so that you have it for reference.
Thanks a million guys, very much appreciated!
{
"_id" : ObjectId("564d12da1506995581569428"),
"objectClass" : "Origin Data",
"objectCategory" : "Application",
"objectType" : "Customer",
"connection_id" : "562033dfca91840cd0c7c54f",
"connectionName" : "Building Accounts",
"entity_id" : "564149bcca9183a8d0c7c83c",
"objectCreationDate" : "2015-11-19 14:43:40",
"objectCycleID" : "12345678",
"objectStatus" : "PROCESSED",
"objectOrigin" : "Xero",
"objectOriginAPI" : "Profit & Loss",
"objectOriginService" : "Xero API - Profit & Loss v 1.0.0.8",
"objectRawOriginData" : {
"Id" : "d6e7fb37-9f2e-45ae-b0a4-de62aa95a783",
"Status" : "OK",
"ProviderName" : "Xero API Previewer",
"DateTimeUTC" : "/Date(1443405874333)/",
"Reports" : [
{
"ReportID" : "ProfitAndLoss",
"ReportName" : "Profit and Loss",
"ReportType" : "ProfitAndLoss",
"ReportTitles" : [
"Profit & Loss",
"Paddy's markets",
"28 September 2014 to 28 September 2015"
],
"ReportDate" : "28 September 2015",
"UpdatedDateUTC" : "/Date(1443405874333)/",
"Fields" : [],
"Rows" : [
{
"RowType" : "Header",
"Cells" : [
{
"Value" : ""
},
{
"Value" : "28 Sep 15"
}
]
},
{
"RowType" : "Section",
"Title" : "Income",
"Rows" : [
{
"RowType" : "Row",
"Cells" : [
{
"Value" : "Sales",
"Attributes" : [
{
"Value" : "a7e3f9e4-6f63-4b25-ae36-107131e8b9be",
"Id" : "account"
}
]
},
{
"Value" : "5428.64",
"Attributes" : [
{
"Value" : "a7e3f9e4-6f63-4b25-ae36-107131e8b9be",
"Id" : "account"
}
]
}
]
},
{
"RowType" : "SummaryRow",
"Cells" : [
{
"Value" : "Total Income"
},
{
"Value" : "5428.64"
}
]
}
]
},
{
"RowType" : "Section",
"Title" : "Less Cost of Sales",
"Rows" : [
{
"RowType" : "Row",
"Cells" : [
{
"Value" : "Cost of Sales",
"Attributes" : [
{
"Value" : "f78f7118-ad98-4862-a63c-39dd3c5ace8a",
"Id" : "account"
}
]
},
{
"Value" : "100.00",
"Attributes" : [
{
"Value" : "f78f7118-ad98-4862-a63c-39dd3c5ace8a",
"Id" : "account"
}
]
}
]
},
{
"RowType" : "SummaryRow",
"Cells" : [
{
"Value" : "Total Cost of Sales"
},
{
"Value" : "100.00"
}
]
}
]
},
{
"RowType" : "Section",
"Title" : "",
"Rows" : [
{
"RowType" : "Row",
"Cells" : [
{
"Value" : "Gross Profit"
},
{
"Value" : "5328.64"
}
]
}
]
},
{
"RowType" : "Section",
"Title" : "Less Operating Expenses",
"Rows" : [
{
"RowType" : "Row",
"Cells" : [
{
"Value" : "Advertising",
"Attributes" : [
{
"Value" : "67466588-132b-48ce-b897-0ceabffd7a9d",
"Id" : "account"
}
]
},
{
"Value" : "100.00",
"Attributes" : [
{
"Value" : "67466588-132b-48ce-b897-0ceabffd7a9d",
"Id" : "account"
}
]
}
]
},
{
"RowType" : "Row",
"Cells" : [
{
"Value" : "General Expenses",
"Attributes" : [
{
"Value" : "fdb25d7a-2fc8-406a-bf4b-6b4e8014b8cb",
"Id" : "account"
}
]
},
{
"Value" : "100.00",
"Attributes" : [
{
"Value" : "fdb25d7a-2fc8-406a-bf4b-6b4e8014b8cb",
"Id" : "account"
}
]
}
]
},
{
"RowType" : "SummaryRow",
"Cells" : [
{
"Value" : "Total Operating Expenses"
},
{
"Value" : "200.00"
}
]
}
]
},
{
"RowType" : "Section",
"Title" : "",
"Rows" : [
{
"RowType" : "Row",
"Cells" : [
{
"Value" : "Net Profit"
},
{
"Value" : "5128.64"
}
]
}
]
}
]
}
]
}
}
done it, see below, thanks:
db.raw_originBusinessData.aggregate([
{ "$match": {objectOriginAPI : "Profit & Loss"}}
,{ "$unwind": "$objectRawOriginData.Reports" }
,{ "$unwind": "$objectRawOriginData.Reports.Rows" }
,{ "$unwind": "$objectRawOriginData.Reports.Rows.Rows" }
,{ "$group": {"_id": "$_id","accountBalances": { "$push": "$objectRawOriginData.Reports.Rows.Rows.Cells.Value" }
}},
])