From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to display text from HTTP read

I created a VI that makes a HTTP request to a weather API, and I’m trying to display some information. So far I've only been able to display values, but I also want to display the weather description from the code. When I use Match Regular Expression the rest of the code is displayed, and I only want to display the weather description "Haze", or any other weather description. How do I get the VI to only display what's in the [""] block final.JPGfront panel final.JPG

0 Kudos
Message 1 of 4
(1,261 Views)

Obviously, you are doing something wrong but we cannot tell from a picture. Please attach your VI and a sample of the full received string or a valid URL. I am sure there are significantly better and simpler ways to do all this.

0 Kudos
Message 2 of 4
(1,249 Views)
{"request":{"type":"City","query":"Chicago, United States of America","language":"en","unit":"m"},"location":{"name":"Chicago","country":"United States of America","region":"Illinois","lat":"41.850","lon":"-87.650","timezone_id":"America\/Chicago","localtime":"2021-04-26 20:35","localtime_epoch":1619469300,"utc_offset":"-5.0"},"current":{"observation_time":"01:35 AM","temperature":23,"weather_code":116,"weather_icons":["https:\/\/assets.weatherstack.com\/images\/wsymbols01_png_64\/wsymbol_0004_black_low_cloud.png"],"weather_descriptions":["Partly cloudy"],"wind_speed":20,"wind_degree":170,"wind_dir":"S","pressure":1006,"precip":0,"humidity":31,"cloudcover":25,"feelslike":25,"uv_index":5,"visibility":16,"is_day":"no"}}
0 Kudos
Message 3 of 4
(1,226 Views)

I strongly recommend to remove the words "FINAL" from the file name of a draft that's not really working well.

 

You can remove all that duplicate code by using arrays and loops. You can eliminate the extra temperature indicators by showing the digital display of the thermometers.

 

Adding cosmetics to the front panel should be the last step.

 

Your string looks like JSON, so you might be able to use these tools. (I am not familiar with them).

 

Even without that, you can do some rudimentary processing e.g. as in the attached. I show two ways to get the numeric values and you can focus on one. You can get rid of all code in the middle and use the output of the lower code to get the numeric values, of course.

 

altenbach_0-1619562415054.png

 

0 Kudos
Message 4 of 4
(1,202 Views)