I work with a flow in Power Automate. In one of the actions I receive a json object which has a dinamic size. The inside objects have always the same properties but the size of the entire object is dinamic:
Sometimes the output I receive is this:
{
"0": {
"id": 1,
"title": "...",
"url": "https://...",
"slug": "...",
"tags": ["tag1", "tag2", "tag3", "tag4"],
}
}
Or may be like this:
{
"0": {
"id": 1,
"title": "...",
"url": "https://...",
"slug": "...",
"tags": ["tag1", "tag2", "tag3", "tag4"],
},
"5": {
"id": 123,
"title": "...",
"url": "https://...",
"slug": "...",
"tags": ["tag1", "tag2"],
},
"7": {
"id": 456,
"title": "...",
"url": "https://...",
"slug": "...",
"tags": ["tag1", "tag2", "tag3"],
}
}
I would like to know wether is possible to get all the values of a specific key.
The real aim is to get all those values (let's say, the URL) and show them in an email.
Thanks in advance.
Related
I've been told that we have some limitations in front end side and we can't use the normal Eloquent json responses, instead I should prepare responses like:
[
{
"title": null,
"type": "animals",
"description": null,
"items": [
{
"type": "animal",
"content": {
"id": 31,
"image": null,
"name": "Asghar's dog",
"age": null,
"race": null,
"species_id": 1,
"reason": [
"Home"
]
}
}
]
},
{
"title": "Recommend",
"type": "recommendations",
"description": null,
"items": [
{
"type": "self_checks",
"content": {
"type": "prompt",
"title": "Self check for Asghar's dog.",
"description": "A short Self check.",
"cta_text": "Los geht’s"
}
},
{
"type": "worm_checks",
"content": {
"title": "Wurm-Vorsorge für Asghar's dog.",
"description": "Finde heraus, wie hoch das Wurm-Risiko deiner Fellnase ist.",
"cta_text": "Los geht’s",
"health_check_payload": {
"url": "https://****.de/check/worms?utm_term=Worms&utm_content=primer",
"title": "Wurm Check"
}
}
}
]
}
]
I need to know how should I structure my code to avoid code repetition and keep it clean. Also, I'm looking for any document regarding this type of responses.
I'm using Elasticsearch and Grafana to show stock growth, ex,
(price[i]-price[first])/price[first] just like growth rate,
but i don't know how to query
here is the sample data
PUT stock/_doc/1
{
"Code": "0000666",
"Name": "test",
"Price": 0.665,
"Date": "2020-01-01"
}
PUT stock/_doc/2
{
"Code": "0000666",
"Name": "test",
"Price": 0.670,
"Date": "2020-01-02"
}
PUT stock/_doc/3
{
"Code": "0000666",
"Name": "test",
"Price": 0.685,
"Date": "2020-01-03"
}
PUT stock/_doc/4
{
"Code": "0000666",
"Name": "test",
"Price": 0.690,
"Date": "2020-01-04"
}
PUT stock/_doc/5
{
"Code": "0000666",
"Name": "test",
"Price": 0.692,
"Date": "2020-01-05"
}
I used painless ,but it only use on single doc
I used derivative,but it only use on two doc,not the first doc
I have this schema for a json response
{
"title": "Products",
"description": "schema for products",
"type": "array",
"properties": {
"id": {
"description": "id of a product",
"type": "integer"
},
"name": {
"description": "name of the product",
"type": "string"
},
"created_at": {
"description": "record created_at",
"type": "string",
"format": "date-time"
},
"updated_at": {
"description": "record updated_at",
"type": "string",
"format": "date-time"
}
},
"required": ["id", "name"]
}
and I want to match this schema with this json
[{
"id": 1,
"name": "Cricket Ball"
}, {
"id": 2,
"name": "Soccer Ball"
}, {
"id": 3,
"name": "football ball"
}, {
"id": 4,
"name": "Basketball ball"
}, {
"id": 5,
"name": "Table Tennis ball"
}, {
"id": 6,
"name": "Tennis ball"
}]
This schema matches the response but it also matches the schema in which the required field is this
"required": ["ids", "names"]
I think the schema is validated against the array and the objects in the array are not validated.
The way you have it set up now, your properties key refers to the array itself, not to each item, and is being ignored (because arrays don't have properties, they just have items). You need to use the items key to validate each item in the array, like so:
{
"title": "Products",
"description": "schema for products",
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"description": "id of a product",
"type": "integer"
},
"name": {
"description": "name of the product",
"type": "string"
},
"created_at": {
"description": "record created_at",
"type": "string",
"format": "date-time"
},
"updated_at": {
"description": "record updated_at",
"type": "string",
"format": "date-time"
}
},
"required": ["id", "name"]
}
}
try map
new_array = response.map{ |k| { 'id': k['properties']['id']['description'], 'name': k['properties']['name']['description'] } }
H have json document with array. As I can't add to beginning of array with push or addtoset I need to sort array. Example
{
"Component": [
{
"Id": "PDP-1",
"Links": {"Link": [
{
"Text": "Western Division",
"Url": "/1x7-en70ai/last-minute-holidays-western-division",
"Title": "Last minute holidays Western Division"
},
{
"Text": "Browse Regions ",
"Url": "/1x7-en6uly-10ts/last-minute-holidays-gambia/regions",
"Title": "Last minute holidays Gambia",
"Style": "BrowseForMore"
},
{
"Text": "City of Banjul",
"Url": "/1x6-en6vq7/holidays-city-of-banjul",
"Title": "City of Banjul Holidays"
},
{
"Text": "Western Division",
"Url": "/1x6-en70ai/holidays-western-division",
"Title": "Western Division Holidays"
}
]},
"Title": "Regions",
"Type": "PDP"
},
{
"Id": "PDP-2",
"Links": {"Link": [
{
"Text": "Bijilo",
"Url": "/1x7-enbmy6/last-minute-holidays-bijilo",
"Title": "Last minute holidays Bijilo"
},
{
"Text": "Browse Cities ",
"Url": "/1x7-en6uly-10tt/last-minute-holidays-gambia/cities",
"Title": "Last minute holidays Gambia",
"Style": "BrowseForMore"
},
{
"Text": "Banjul Beach",
"Url": "/1x6-enakgm/holidays-banjul-beach",
"Title": "Banjul Beach Holidays"
},
{
"Text": "Bijilo",
"Url": "/1x6-enbmy6/holidays-bijilo",
"Title": "Bijilo Holidays"
},
{
"Text": "Brufut Heights",
"Url": "/1x6-encok8/holidays-brufut-heights",
"Title": "Brufut Heights Holidays"
},
{
"Text": "Kololi",
"Url": "/1x6-enpnle/holidays-kololi",
"Title": "Kololi Holidays"
},
{
"Text": "Kotu",
"Url": "/1x6-enq067/holidays-kotu",
"Title": "Kotu Holidays"
}
]},
"Title": "Cities",
"Type": "PDP"
}
],
"Id": "118431",
"Template": {
"PageTemplate": {
"Code": "2B2",
"text": "041 - TEMP2 - COP_CONCOU_{LAST MINUTE}"
},
"Category": {
"Code": "1X7",
"Type": "Product",
"text": "Last minute holidays"
},
"GeoObject": {
"Code": "EN6ULY",
"text": "Gambia, The"
},
"GeoObjectType": {
"Code": "1A",
"text": "Political"
},
"GeoObjectSubType": {
"Code": "10TR",
"text": "Country"
}
},
"Type": "Content",
"Url": "/1x7-en6uly/last-minute-holidays-gambia",
"_id": {"$oid": "528492d4c90fa9fcd0436929"}
}
I want to sort this by Style in Links.Link 'BrowseForMore'. Any idea how to do it? I thought I could add dummy array with push which could then sort it the way I want. Any help appreciated
You appear to want to update the array and keep the sort order with your Links.Link.Style value at the front of the list. In which case use the $sort modifier with update.
db.collection.update(
{ _id: id },
{ $push: { "Links.Link: {$each: [doc], $sort { Style: -1 }}} }
)
The $each operator is required even if there is only one document, but can take many.
if you are trying to use $addToSet to maintain unique documents the official MongoDB line is that sets are considered to be unordered and hence the modifiers are not available here.
Why doesn't a timeline item with this payload offer the turn by turn navigation options from Google Glass, is there a bug ? If the answer is because it needs more properties set that sucks to make us call another endpoint.
{
"kind": "mirror#timelineItem",
"id": "035cb808-a908-4057-914f-f980fb35c620",
"bundleId": "12",
"created": "2013-08-21T22:52:54.635Z",
"updated": "2013-08-21T22:52:54.635Z",
"etag": "\"hzfI85yu0lKQdtWV4PO1jAbQxWw/UvNo_kKkfbIjHfhmNjOLyMSNIeA\"",
"creator": {
"kind": "mirror#contact",
"source": "api:34091916267",
"id": "70",
"displayName": "Monica Wilkinson"
},
"title": "glass-4",
"text": "...",
"html": "....",
"speakableText": "...",
"location": {
"kind": "mirror#location",
"latitude": 37.7657774,
"longitude": -122.4075774,
"displayName": "Crushpath Labs"
},
"menuItems": [
{
"action": "NAVIGATE"
}
]
}
Try this:
"location": {
"latitude": 37.7657774,
"longitude": -122.4075774,
"accuracy": 36.0
},
It works for me.