web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Extracting an array of...
Power Automate
Unanswered

Extracting an array of the latest timestamp from JSON

(0) ShareShare
ReportReport
Posted on by 98

Below is a json formatted weather report. I want to extract an array of the latest time stamp, and make it html. How can I achieve this?

 

{
"body": {
"20240619090000": {
"prefNumber": 44,
"observationNumber": 132,
"pressure": [
1006.7,
0
],
"normalPressure": [
1009.5,
0
],
"temp": [
24.3,
0
],
"humidity": [
66,
0
],
"snow": [
null,
5
],
"snow1h": [
0,
6
],
"snow6h": [
0,
6
],
"snow12h": [
0,
6
],
"snow24h": [
0,
6
],
"sun10m": [
10,
0
],
"sun1h": [
1,
0
],
"precipitation10m": [
0,
0
],
"precipitation1h": [
0,
0
],
"precipitation3h": [
0,
0
],
"precipitation24h": [
70.5,
0
],
"windDirection": [
16,
0
],
"wind": [
2.2,
0
],
"maxTempTime": {
"hour": 23,
"minute": 50
},
"maxTemp": [
24.8,
0
],
"minTempTime": {
"hour": 19,
"minute": 31
},
"minTemp": [
17.2,
0
],
"gustTime": {
"hour": 23,
"minute": 46
},
"gustDirection": [
16,
0
],
"gust": [
6.1,
0
]
},
"20240619091000": {
"prefNumber": 44,
"observationNumber": 132,
"pressure": [
1006.6,
0
],
"normalPressure": [
1009.4,
0
],
"temp": [
24.6,
0
],
"humidity": [
63,
0
],
"sun10m": [
10,
0
],
"sun1h": [
1,
0
],
"precipitation10m": [
0,
0
],
"precipitation1h": [
0,
0
],
"precipitation3h": [
0,
0
],
"precipitation24h": [
68,
0
],
"windDirection": [
15,
0
],
"wind": [
3.3,
0
],
"maxTempTime": {
"hour": 0,
"minute": 9
},
"maxTemp": [
25.4,
0
],
"minTempTime": {
"hour": 19,
"minute": 31
},
"minTemp": [
17.2,
0
],
"gustTime": {
"hour": 23,
"minute": 46
},
"gustDirection": [
16,
0
],
"gust": [
6.1,
0
]
}

}
}

Categories:
I have the same question (0)
  • v-yueyun-msft Profile Picture
    on at

    Hi , @KenJapan 

    Can you give me a sample end result you want to get in your side ?

     

    Best Regards,

    Yueyun Zhang

     

  • KenJapan Profile Picture
    98 on at

    Sure, here is what I want to acheive,

     

    Timestamp: 2024-06-19 09:00:00
    Wind Speed: 2.2 m/s
    Wind Direction: 16 degrees

     

    Thank you!

  • v-yueyun-msft Profile Picture
    on at

    Hi , @KenJapan 

    Thanks for your response! The Latest time stamp is "20240619091000" which is "2024-06-19 09:10:00". Right?

    The  "20240619091000" is later then "20240619090000".

     

    Best Regards,

    Yueyun Zhang

     

     

  • KenJapan Profile Picture
    98 on at

    That's right, my bad

  • Verified answer
    v-yueyun-msft Profile Picture
    on at

    Hi , @KenJapan 

    Thanks for your response , i create a sample test flow , in my Compose action, i use to create the same json as test data:

    vyueyunmsft_0-1718848991001.png

     

    You can refer to my flow:

    vyueyunmsft_1-1718849104850.png

     

    xpath(xml(json(concat('{ "root": ', string(outputs('Compose')?['body'] ), ' }') )) ,'/root/*')

    xpath(item(),'name(/*)')

     

    concat(
    substring(replace( replace(last(sort(body('Select'))) , '_','' ) , 'x003' , '' ),0,4) , '-',
    substring(replace( replace(last(sort(body('Select'))) , '_','' ) , 'x003' , '' ),4,2) ,'-' ,
    substring(replace( replace(last(sort(body('Select'))) , '_','' ) , 'x003' , '' ),6,2),' ',
    substring(replace( replace(last(sort(body('Select'))) , '_','' ) , 'x003' , '' ),8,2) , ':',
    substring(replace( replace(last(sort(body('Select'))) , '_','' ) , 'x003' , '' ),10,2) , ':',
    substring(replace( replace(last(sort(body('Select'))) , '_','' ) , 'x003' , '' ),12,2) )

     

    outputs('Compose')?['body']?[replace( replace(last(sort(body('Select'))) , '_','' ) , 'x003' , '' )]?['wind']?[0]

    outputs('Compose')?['body']?[replace( replace(last(sort(body('Select'))) , '_','' ) , 'x003' , '' )]?['windDirection']?[0]

     

    You need replce the red font color in your side which is return the json object.

     

    If this reply can help you , you can click mark this reply as solution (Accept solution) which can help more people, thanks in advance! 

     

    Best Regards,

    Yueyun Zhang

     

     

     

  • KenJapan Profile Picture
    98 on at

    Works perfectly, thanks!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard