Extract data from API

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Extract data from API

Laurent Gigon
Hi,

What is the best way to extract data, ex. EUR value, in this case ?

https://api.exchangeratesapi.io/latest?base=USD

it returns:

{"rates":{"PHP":52.1603814478,"HUF":278.4221933247,"IDR":14079.0030342436,"TRY":5.4364109233,"RON":4.0583441699,"ISK":118.855656697,"ILS":3.6637191157,"CNY":6.7804941482,"USD":1.0,"EUR":0.8669267447,"PLN":3.7242306025,"GBP":0.7839011704,"CAD":1.3221499783,"AUD":1.3897702644,"MYR":4.0975292588,"NZD":1.4723016905,"CHF":0.9775465973,"HRK":6.4373645427,"SGD":1.3510186389,"DKK":6.4720416125,"BGN":1.6955353273,"CZK":22.2158647594,"BRL":3.6801907239,"JPY":108.1057650629,"KRW":1117.5032509753,"INR":70.3948851322,"SEK":8.8689206762,"MXN":19.1836150845,"RUB":66.9693107932,"HKD":7.8382314694,"ZAR":13.8475075856,"THB":31.9046380581,"NOK":8.451928912},"base":"USD","date":"2019-01-10"}

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Extract data from API

Jolle Carlestam-2
Lasso 8 or 9?

HDB
Jolle

Sent from a mobile device. Any anomalies is due to Autocorrect.

> 10 jan. 2019 kl. 17:51 skrev Laurent G <[hidden email]>:
>
> Hi,
>
> What is the best way to extract data, ex. EUR value, in this case ?
>
> https://api.exchangeratesapi.io/latest?base=USD
>
> it returns:
>
> {"rates":{"PHP":52.1603814478,"HUF":278.4221933247,"IDR":14079.0030342436,"TRY":5.4364109233,"RON":4.0583441699,"ISK":118.855656697,"ILS":3.6637191157,"CNY":6.7804941482,"USD":1.0,"EUR":0.8669267447,"PLN":3.7242306025,"GBP":0.7839011704,"CAD":1.3221499783,"AUD":1.3897702644,"MYR":4.0975292588,"NZD":1.4723016905,"CHF":0.9775465973,"HRK":6.4373645427,"SGD":1.3510186389,"DKK":6.4720416125,"BGN":1.6955353273,"CZK":22.2158647594,"BRL":3.6801907239,"JPY":108.1057650629,"KRW":1117.5032509753,"INR":70.3948851322,"SEK":8.8689206762,"MXN":19.1836150845,"RUB":66.9693107932,"HKD":7.8382314694,"ZAR":13.8475075856,"THB":31.9046380581,"NOK":8.451928912},"base":"USD","date":"2019-01-10"}
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Extract data from API

Laurent Gigon
sorry, Lasso 8

Le jeu. 10 janv. 2019 à 12:32, Jolle Carlestam <[hidden email]> a écrit :

>
> Lasso 8 or 9?
>
> HDB
> Jolle
>
> Sent from a mobile device. Any anomalies is due to Autocorrect.
>
> > 10 jan. 2019 kl. 17:51 skrev Laurent G <[hidden email]>:
> >
> > Hi,
> >
> > What is the best way to extract data, ex. EUR value, in this case ?
> >
> > https://api.exchangeratesapi.io/latest?base=USD
> >
> > it returns:
> >
> > {"rates":{"PHP":52.1603814478,"HUF":278.4221933247,"IDR":14079.0030342436,"TRY":5.4364109233,"RON":4.0583441699,"ISK":118.855656697,"ILS":3.6637191157,"CNY":6.7804941482,"USD":1.0,"EUR":0.8669267447,"PLN":3.7242306025,"GBP":0.7839011704,"CAD":1.3221499783,"AUD":1.3897702644,"MYR":4.0975292588,"NZD":1.4723016905,"CHF":0.9775465973,"HRK":6.4373645427,"SGD":1.3510186389,"DKK":6.4720416125,"BGN":1.6955353273,"CZK":22.2158647594,"BRL":3.6801907239,"JPY":108.1057650629,"KRW":1117.5032509753,"INR":70.3948851322,"SEK":8.8689206762,"MXN":19.1836150845,"RUB":66.9693107932,"HKD":7.8382314694,"ZAR":13.8475075856,"THB":31.9046380581,"NOK":8.451928912},"base":"USD","date":"2019-01-10"}
> >
> > #############################################################
> >
> > This message is sent to you because you are subscribed to
> >  the mailing list Lasso [hidden email]
> > Official list archives available at http://www.lassotalk.com
> > To unsubscribe, E-mail to: <[hidden email]>
> > Send administrative queries to  <[hidden email]>
>
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>   the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Extract data from API

Jolle Carlestam-2
In reply to this post by Jolle Carlestam-2
Anyway, assuming this is Lasso 9. The data you’re grabbing is in JSON. You need to extract it from the raw json and, in this case tur nit into a map of maps.

local(incoming_json = '{"rates":{"PHP":52.1603814478,"HUF":278.4221933247,"IDR":14079.0030342436,"TRY":5.4364109233,"RON":4.0583441699,"ISK":118.855656697,"ILS":3.6637191157,"CNY":6.7804941482,"USD":1.0,"EUR":0.8669267447,"PLN":3.7242306025,"GBP":0.7839011704,"CAD":1.3221499783,"AUD":1.3897702644,"MYR":4.0975292588,"NZD":1.4723016905,"CHF":0.9775465973,"HRK":6.4373645427,"SGD":1.3510186389,"DKK":6.4720416125,"BGN":1.6955353273,"CZK":22.2158647594,"BRL":3.6801907239,"JPY":108.1057650629,"KRW":1117.5032509753,"INR":70.3948851322,"SEK":8.8689206762,"MXN":19.1836150845,"RUB":66.9693107932,"HKD":7.8382314694,"ZAR":13.8475075856,"THB":31.9046380581,"NOK":8.451928912},"base":"USD","date":"2019-01-10"}
')

local(incoming_data = json_decode(#incoming_json) or map)

local(rates = #incoming_data->find('rates') or map)

local(eur = #rates->find('EUR'))

#eur

-> 0.866927

HDB
Jolle

> 10 jan. 2019 kl. 18:31 skrev Jolle Carlestam <[hidden email]>:
>
> Lasso 8 or 9?
>
> HDB
> Jolle
>
> Sent from a mobile device. Any anomalies is due to Autocorrect.
>
>> 10 jan. 2019 kl. 17:51 skrev Laurent G <[hidden email]>:
>>
>> Hi,
>>
>> What is the best way to extract data, ex. EUR value, in this case ?
>>
>> https://api.exchangeratesapi.io/latest?base=USD
>>
>> it returns:
>>
>> {"rates":{"PHP":52.1603814478,"HUF":278.4221933247,"IDR":14079.0030342436,"TRY":5.4364109233,"RON":4.0583441699,"ISK":118.855656697,"ILS":3.6637191157,"CNY":6.7804941482,"USD":1.0,"EUR":0.8669267447,"PLN":3.7242306025,"GBP":0.7839011704,"CAD":1.3221499783,"AUD":1.3897702644,"MYR":4.0975292588,"NZD":1.4723016905,"CHF":0.9775465973,"HRK":6.4373645427,"SGD":1.3510186389,"DKK":6.4720416125,"BGN":1.6955353273,"CZK":22.2158647594,"BRL":3.6801907239,"JPY":108.1057650629,"KRW":1117.5032509753,"INR":70.3948851322,"SEK":8.8689206762,"MXN":19.1836150845,"RUB":66.9693107932,"HKD":7.8382314694,"ZAR":13.8475075856,"THB":31.9046380581,"NOK":8.451928912},"base":"USD","date":"2019-01-10"}
>>
>> #############################################################
>>
>> This message is sent to you because you are subscribed to
>> the mailing list Lasso [hidden email]
>> Official list archives available at http://www.lassotalk.com
>> To unsubscribe, E-mail to: <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Extract data from API

Jolle Carlestam-2
In reply to this post by Laurent Gigon
Ah, sorry about that. I don’t do 8. Best of luck. I’m sure there’s an equivalent method in 8.

HDB
Jolle

> 10 jan. 2019 kl. 18:41 skrev Laurent G <[hidden email]>:
>
> sorry, Lasso 8


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Extract data from API

French, Shelane
In reply to this post by Laurent Gigon
var('results' = include_url(' https://api.exchangeratesapi.io/latest', -GetParams=array('base'='USD')));
$results = decode_json($results);
var('rates' = $results->find('rates'));


On 1/10/19, 8:52 AM, "[hidden email] on behalf of Laurent G" <[hidden email] on behalf of [hidden email]> wrote:

    Hi,
   
    What is the best way to extract data, ex. EUR value, in this case ?
   
    https://api.exchangeratesapi.io/latest?base=USD
   
    it returns:
   
    {"rates":{"PHP":52.1603814478,"HUF":278.4221933247,"IDR":14079.0030342436,"TRY":5.4364109233,"RON":4.0583441699,"ISK":118.855656697,"ILS":3.6637191157,"CNY":6.7804941482,"USD":1.0,"EUR":0.8669267447,"PLN":3.7242306025,"GBP":0.7839011704,"CAD":1.3221499783,"AUD":1.3897702644,"MYR":4.0975292588,"NZD":1.4723016905,"CHF":0.9775465973,"HRK":6.4373645427,"SGD":1.3510186389,"DKK":6.4720416125,"BGN":1.6955353273,"CZK":22.2158647594,"BRL":3.6801907239,"JPY":108.1057650629,"KRW":1117.5032509753,"INR":70.3948851322,"SEK":8.8689206762,"MXN":19.1836150845,"RUB":66.9693107932,"HKD":7.8382314694,"ZAR":13.8475075856,"THB":31.9046380581,"NOK":8.451928912},"base":"USD","date":"2019-01-10"}
   
    #############################################################
   
    This message is sent to you because you are subscribed to
      the mailing list Lasso [hidden email]
    Official list archives available at http://www.lassotalk.com
    To unsubscribe, E-mail to: <[hidden email]>
    Send administrative queries to  <[hidden email]>
   


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Extract data from API

Bil Corry-3
In reply to this post by Laurent Gigon
You can use regex to extract the value.  I no longer have Lasso installed
to figure out the exact Lasso code, but this is the regex to find the EUR
value:

(?<=EUR\":)\d+.?\d*


For Lasso, it will be something like this (I've doubled up the backslashes
as I think that's still required for Lasso):

string_findregexp($rates,-find='(?<=EUR\\":)\\d+.?\\d*');



- Bil




On Thu, Jan 10, 2019 at 9:51 AM Laurent G <[hidden email]> wrote:

> Hi,
>
> What is the best way to extract data, ex. EUR value, in this case ?
>
> https://api.exchangeratesapi.io/latest?base=USD
>
> it returns:
>
>
> {"rates":{"PHP":52.1603814478,"HUF":278.4221933247,"IDR":14079.0030342436,"TRY":5.4364109233,"RON":4.0583441699,"ISK":118.855656697,"ILS":3.6637191157,"CNY":6.7804941482,"USD":1.0,"EUR":0.8669267447,"PLN":3.7242306025,"GBP":0.7839011704,"CAD":1.3221499783,"AUD":1.3897702644,"MYR":4.0975292588,"NZD":1.4723016905,"CHF":0.9775465973,"HRK":6.4373645427,"SGD":1.3510186389,"DKK":6.4720416125,"BGN":1.6955353273,"CZK":22.2158647594,"BRL":3.6801907239,"JPY":108.1057650629,"KRW":1117.5032509753,"INR":70.3948851322,"SEK":8.8689206762,"MXN":19.1836150845,"RUB":66.9693107932,"HKD":7.8382314694,"ZAR":13.8475075856,"THB":31.9046380581,"NOK":8.451928912},"base":"USD","date":"2019-01-10"}
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>   the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>
>

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Extract data from API

Laurent Gigon
Thank you Bil!

it returns : array: (0.6556947085)
Ho to get rid of "array" ?

Le jeu. 10 janv. 2019 à 14:00, Bil Corry <[hidden email]> a écrit :

>
> You can use regex to extract the value.  I no longer have Lasso installed
> to figure out the exact Lasso code, but this is the regex to find the EUR
> value:
>
> (?<=EUR\":)\d+.?\d*
>
>
> For Lasso, it will be something like this (I've doubled up the backslashes
> as I think that's still required for Lasso):
>
> string_findregexp($rates,-find='(?<=EUR\\":)\\d+.?\\d*');
>
>
>
> - Bil
>
>
>
>
> On Thu, Jan 10, 2019 at 9:51 AM Laurent G <[hidden email]> wrote:
>
> > Hi,
> >
> > What is the best way to extract data, ex. EUR value, in this case ?
> >
> > https://api.exchangeratesapi.io/latest?base=USD
> >
> > it returns:
> >
> >
> > {"rates":{"PHP":52.1603814478,"HUF":278.4221933247,"IDR":14079.0030342436,"TRY":5.4364109233,"RON":4.0583441699,"ISK":118.855656697,"ILS":3.6637191157,"CNY":6.7804941482,"USD":1.0,"EUR":0.8669267447,"PLN":3.7242306025,"GBP":0.7839011704,"CAD":1.3221499783,"AUD":1.3897702644,"MYR":4.0975292588,"NZD":1.4723016905,"CHF":0.9775465973,"HRK":6.4373645427,"SGD":1.3510186389,"DKK":6.4720416125,"BGN":1.6955353273,"CZK":22.2158647594,"BRL":3.6801907239,"JPY":108.1057650629,"KRW":1117.5032509753,"INR":70.3948851322,"SEK":8.8689206762,"MXN":19.1836150845,"RUB":66.9693107932,"HKD":7.8382314694,"ZAR":13.8475075856,"THB":31.9046380581,"NOK":8.451928912},"base":"USD","date":"2019-01-10"}
> >
> > #############################################################
> >
> > This message is sent to you because you are subscribed to
> >   the mailing list Lasso [hidden email]
> > Official list archives available at http://www.lassotalk.com
> > To unsubscribe, E-mail to: <[hidden email]>
> > Send administrative queries to  <[hidden email]>
> >
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>   the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Extract data from API

Steffan A. Cline
Add ->first to the end of the regex statement.

Thanks,
Steffan Cline
[hidden email]
602-793-0014

> On Jan 10, 2019, at 1:35 PM, Laurent G <[hidden email]> wrote:
>
> Thank you Bil!
>
> it returns : array: (0.6556947085)
> Ho to get rid of "array" ?
>
>> Le jeu. 10 janv. 2019 à 14:00, Bil Corry <[hidden email]> a écrit :
>>
>> You can use regex to extract the value.  I no longer have Lasso installed
>> to figure out the exact Lasso code, but this is the regex to find the EUR
>> value:
>>
>> (?<=EUR\":)\d+.?\d*
>>
>>
>> For Lasso, it will be something like this (I've doubled up the backslashes
>> as I think that's still required for Lasso):
>>
>> string_findregexp($rates,-find='(?<=EUR\\":)\\d+.?\\d*');
>>
>>
>>
>> - Bil
>>
>>
>>
>>
>>> On Thu, Jan 10, 2019 at 9:51 AM Laurent G <[hidden email]> wrote:
>>>
>>> Hi,
>>>
>>> What is the best way to extract data, ex. EUR value, in this case ?
>>>
>>> https://api.exchangeratesapi.io/latest?base=USD
>>>
>>> it returns:
>>>
>>>
>>> {"rates":{"PHP":52.1603814478,"HUF":278.4221933247,"IDR":14079.0030342436,"TRY":5.4364109233,"RON":4.0583441699,"ISK":118.855656697,"ILS":3.6637191157,"CNY":6.7804941482,"USD":1.0,"EUR":0.8669267447,"PLN":3.7242306025,"GBP":0.7839011704,"CAD":1.3221499783,"AUD":1.3897702644,"MYR":4.0975292588,"NZD":1.4723016905,"CHF":0.9775465973,"HRK":6.4373645427,"SGD":1.3510186389,"DKK":6.4720416125,"BGN":1.6955353273,"CZK":22.2158647594,"BRL":3.6801907239,"JPY":108.1057650629,"KRW":1117.5032509753,"INR":70.3948851322,"SEK":8.8689206762,"MXN":19.1836150845,"RUB":66.9693107932,"HKD":7.8382314694,"ZAR":13.8475075856,"THB":31.9046380581,"NOK":8.451928912},"base":"USD","date":"2019-01-10"}
>>>
>>> #############################################################
>>>
>>> This message is sent to you because you are subscribed to
>>>  the mailing list Lasso [hidden email]
>>> Official list archives available at http://www.lassotalk.com
>>> To unsubscribe, E-mail to: <[hidden email]>
>>> Send administrative queries to  <[hidden email]>
>>>
>>
>> #############################################################
>>
>> This message is sent to you because you are subscribed to
>>  the mailing list Lasso [hidden email]
>> Official list archives available at http://www.lassotalk.com
>> To unsubscribe, E-mail to: <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Extract data from API

Laurent Gigon
wow! so fast!! thanks guys!

Le jeu. 10 janv. 2019 à 15:36, Steffan Cline <[hidden email]> a écrit :

>
> Add ->first to the end of the regex statement.
>
> Thanks,
> Steffan Cline
> [hidden email]
> 602-793-0014
>
> > On Jan 10, 2019, at 1:35 PM, Laurent G <[hidden email]> wrote:
> >
> > Thank you Bil!
> >
> > it returns : array: (0.6556947085)
> > Ho to get rid of "array" ?
> >
> >> Le jeu. 10 janv. 2019 à 14:00, Bil Corry <[hidden email]> a écrit :
> >>
> >> You can use regex to extract the value.  I no longer have Lasso installed
> >> to figure out the exact Lasso code, but this is the regex to find the EUR
> >> value:
> >>
> >> (?<=EUR\":)\d+.?\d*
> >>
> >>
> >> For Lasso, it will be something like this (I've doubled up the backslashes
> >> as I think that's still required for Lasso):
> >>
> >> string_findregexp($rates,-find='(?<=EUR\\":)\\d+.?\\d*');
> >>
> >>
> >>
> >> - Bil
> >>
> >>
> >>
> >>
> >>> On Thu, Jan 10, 2019 at 9:51 AM Laurent G <[hidden email]> wrote:
> >>>
> >>> Hi,
> >>>
> >>> What is the best way to extract data, ex. EUR value, in this case ?
> >>>
> >>> https://api.exchangeratesapi.io/latest?base=USD
> >>>
> >>> it returns:
> >>>
> >>>
> >>> {"rates":{"PHP":52.1603814478,"HUF":278.4221933247,"IDR":14079.0030342436,"TRY":5.4364109233,"RON":4.0583441699,"ISK":118.855656697,"ILS":3.6637191157,"CNY":6.7804941482,"USD":1.0,"EUR":0.8669267447,"PLN":3.7242306025,"GBP":0.7839011704,"CAD":1.3221499783,"AUD":1.3897702644,"MYR":4.0975292588,"NZD":1.4723016905,"CHF":0.9775465973,"HRK":6.4373645427,"SGD":1.3510186389,"DKK":6.4720416125,"BGN":1.6955353273,"CZK":22.2158647594,"BRL":3.6801907239,"JPY":108.1057650629,"KRW":1117.5032509753,"INR":70.3948851322,"SEK":8.8689206762,"MXN":19.1836150845,"RUB":66.9693107932,"HKD":7.8382314694,"ZAR":13.8475075856,"THB":31.9046380581,"NOK":8.451928912},"base":"USD","date":"2019-01-10"}
> >>>
> >>> #############################################################
> >>>
> >>> This message is sent to you because you are subscribed to
> >>>  the mailing list Lasso [hidden email]
> >>> Official list archives available at http://www.lassotalk.com
> >>> To unsubscribe, E-mail to: <[hidden email]>
> >>> Send administrative queries to  <[hidden email]>
> >>>
> >>
> >> #############################################################
> >>
> >> This message is sent to you because you are subscribed to
> >>  the mailing list Lasso [hidden email]
> >> Official list archives available at http://www.lassotalk.com
> >> To unsubscribe, E-mail to: <[hidden email]>
> >> Send administrative queries to  <[hidden email]>
> >
> > #############################################################
> >
> > This message is sent to you because you are subscribed to
> >  the mailing list Lasso [hidden email]
> > Official list archives available at http://www.lassotalk.com
> > To unsubscribe, E-mail to: <[hidden email]>
> > Send administrative queries to  <[hidden email]>
>
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>   the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Extract data from API

French, Shelane
That's seriously over complicating it...


var('results' = include_url('https://api.exchangeratesapi.io/latest', -GetParams=array('base'='USD')));
$results = decode_json($results);
var('rates' = $results->find('rates'));
$rates->find('EUR');

On 1/10/19, 12:38 PM, "[hidden email] on behalf of Laurent G" <[hidden email] on behalf of [hidden email]> wrote:

    wow! so fast!! thanks guys!
   
    Le jeu. 10 janv. 2019 à 15:36, Steffan Cline <[hidden email]> a écrit :
    >
    > Add ->first to the end of the regex statement.
    >
    > Thanks,
    > Steffan Cline
    > [hidden email]
    > 602-793-0014
    >
    > > On Jan 10, 2019, at 1:35 PM, Laurent G <[hidden email]> wrote:
    > >
    > > Thank you Bil!
    > >
    > > it returns : array: (0.6556947085)
    > > Ho to get rid of "array" ?
    > >
    > >> Le jeu. 10 janv. 2019 à 14:00, Bil Corry <[hidden email]> a écrit :
    > >>
    > >> You can use regex to extract the value.  I no longer have Lasso installed
    > >> to figure out the exact Lasso code, but this is the regex to find the EUR
    > >> value:
    > >>
    > >> (?<=EUR\":)\d+.?\d*
    > >>
    > >>
    > >> For Lasso, it will be something like this (I've doubled up the backslashes
    > >> as I think that's still required for Lasso):
    > >>
    > >> string_findregexp($rates,-find='(?<=EUR\\":)\\d+.?\\d*');
    > >>
    > >>
    > >>
    > >> - Bil
    > >>
    > >>
    > >>
    > >>
    > >>> On Thu, Jan 10, 2019 at 9:51 AM Laurent G <[hidden email]> wrote:
    > >>>
    > >>> Hi,
    > >>>
    > >>> What is the best way to extract data, ex. EUR value, in this case ?
    > >>>
    > >>> https://api.exchangeratesapi.io/latest?base=USD
    > >>>
    > >>> it returns:
    > >>>
    > >>>
    > >>> {"rates":{"PHP":52.1603814478,"HUF":278.4221933247,"IDR":14079.0030342436,"TRY":5.4364109233,"RON":4.0583441699,"ISK":118.855656697,"ILS":3.6637191157,"CNY":6.7804941482,"USD":1.0,"EUR":0.8669267447,"PLN":3.7242306025,"GBP":0.7839011704,"CAD":1.3221499783,"AUD":1.3897702644,"MYR":4.0975292588,"NZD":1.4723016905,"CHF":0.9775465973,"HRK":6.4373645427,"SGD":1.3510186389,"DKK":6.4720416125,"BGN":1.6955353273,"CZK":22.2158647594,"BRL":3.6801907239,"JPY":108.1057650629,"KRW":1117.5032509753,"INR":70.3948851322,"SEK":8.8689206762,"MXN":19.1836150845,"RUB":66.9693107932,"HKD":7.8382314694,"ZAR":13.8475075856,"THB":31.9046380581,"NOK":8.451928912},"base":"USD","date":"2019-01-10"}
    > >>>
    > >>> #############################################################
    > >>>
    > >>> This message is sent to you because you are subscribed to
    > >>>  the mailing list Lasso [hidden email]
    > >>> Official list archives available at http://www.lassotalk.com
    > >>> To unsubscribe, E-mail to: <[hidden email]>
    > >>> Send administrative queries to  <[hidden email]>
    > >>>
    > >>
    > >> #############################################################
    > >>
    > >> This message is sent to you because you are subscribed to
    > >>  the mailing list Lasso [hidden email]
    > >> Official list archives available at http://www.lassotalk.com
    > >> To unsubscribe, E-mail to: <[hidden email]>
    > >> Send administrative queries to  <[hidden email]>
    > >
    > > #############################################################
    > >
    > > This message is sent to you because you are subscribed to
    > >  the mailing list Lasso [hidden email]
    > > Official list archives available at http://www.lassotalk.com
    > > To unsubscribe, E-mail to: <[hidden email]>
    > > Send administrative queries to  <[hidden email]>
    >
    >
    > #############################################################
    >
    > This message is sent to you because you are subscribed to
    >   the mailing list Lasso [hidden email]
    > Official list archives available at http://www.lassotalk.com
    > To unsubscribe, E-mail to: <[hidden email]>
    > Send administrative queries to  <[hidden email]>
   
    #############################################################
   
    This message is sent to you because you are subscribed to
      the mailing list Lasso [hidden email]
    Official list archives available at http://www.lassotalk.com
    To unsubscribe, E-mail to: <[hidden email]>
    Send administrative queries to  <[hidden email]>


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Extract data from API

Bil Corry-3
Hi Shelane,

Thank you for your code example.  I'm replying because your email ended
up in my spam folder and I want to make sure others see it in case they
have the same issue.

- Bil


On Thu, Jan 10, 2019 at 1:40 PM French, Shelane <[hidden email]> wrote:

> That's seriously over complicating it...
>
>
> var('results' = include_url('https://api.exchangeratesapi.io/latest',
> -GetParams=array('base'='USD')));
> $results = decode_json($results);
> var('rates' = $results->find('rates'));
> $rates->find('EUR');
>
> On 1/10/19, 12:38 PM, "[hidden email] on behalf of
> Laurent G" <[hidden email] on behalf of
> [hidden email]> wrote:
>
>     wow! so fast!! thanks guys!
>
>     Le jeu. 10 janv. 2019 à 15:36, Steffan Cline <[hidden email]> a
> écrit :
>     >
>     > Add ->first to the end of the regex statement.
>     >
>     > Thanks,
>     > Steffan Cline
>     > [hidden email]
>     > 602-793-0014
>     >
>     > > On Jan 10, 2019, at 1:35 PM, Laurent G <[hidden email]>
> wrote:
>     > >
>     > > Thank you Bil!
>     > >
>     > > it returns : array: (0.6556947085)
>     > > Ho to get rid of "array" ?
>     > >
>     > >> Le jeu. 10 janv. 2019 à 14:00, Bil Corry <[hidden email]> a écrit
> :
>     > >>
>     > >> You can use regex to extract the value.  I no longer have Lasso
> installed
>     > >> to figure out the exact Lasso code, but this is the regex to find
> the EUR
>     > >> value:
>     > >>
>     > >> (?<=EUR\":)\d+.?\d*
>     > >>
>     > >>
>     > >> For Lasso, it will be something like this (I've doubled up the
> backslashes
>     > >> as I think that's still required for Lasso):
>     > >>
>     > >> string_findregexp($rates,-find='(?<=EUR\\":)\\d+.?\\d*');
>     > >>
>     > >>
>     > >>
>     > >> - Bil
>     > >>
>     > >>
>     > >>
>     > >>
>     > >>> On Thu, Jan 10, 2019 at 9:51 AM Laurent G <[hidden email]>
> wrote:
>     > >>>
>     > >>> Hi,
>     > >>>
>     > >>> What is the best way to extract data, ex. EUR value, in this
> case ?
>     > >>>
>     > >>> https://api.exchangeratesapi.io/latest?base=USD
>     > >>>
>     > >>> it returns:
>     > >>>
>     > >>>
>     > >>>
> {"rates":{"PHP":52.1603814478,"HUF":278.4221933247,"IDR":14079.0030342436,"TRY":5.4364109233,"RON":4.0583441699,"ISK":118.855656697,"ILS":3.6637191157,"CNY":6.7804941482,"USD":1.0,"EUR":0.8669267447,"PLN":3.7242306025,"GBP":0.7839011704,"CAD":1.3221499783,"AUD":1.3897702644,"MYR":4.0975292588,"NZD":1.4723016905,"CHF":0.9775465973,"HRK":6.4373645427,"SGD":1.3510186389,"DKK":6.4720416125,"BGN":1.6955353273,"CZK":22.2158647594,"BRL":3.6801907239,"JPY":108.1057650629,"KRW":1117.5032509753,"INR":70.3948851322,"SEK":8.8689206762,"MXN":19.1836150845,"RUB":66.9693107932,"HKD":7.8382314694,"ZAR":13.8475075856,"THB":31.9046380581,"NOK":8.451928912},"base":"USD","date":"2019-01-10"}
>     > >>>
>     > >>> #############################################################
>     > >>>
>     > >>> This message is sent to you because you are subscribed to
>     > >>>  the mailing list Lasso [hidden email]
>     > >>> Official list archives available at http://www.lassotalk.com
>     > >>> To unsubscribe, E-mail to: <
> [hidden email]>
>     > >>> Send administrative queries to  <
> [hidden email]>
>     > >>>
>     > >>
>     > >> #############################################################
>     > >>
>     > >> This message is sent to you because you are subscribed to
>     > >>  the mailing list Lasso [hidden email]
>     > >> Official list archives available at http://www.lassotalk.com
>     > >> To unsubscribe, E-mail to: <[hidden email]
> >
>     > >> Send administrative queries to  <
> [hidden email]>
>     > >
>     > > #############################################################
>     > >
>     > > This message is sent to you because you are subscribed to
>     > >  the mailing list Lasso [hidden email]
>     > > Official list archives available at http://www.lassotalk.com
>     > > To unsubscribe, E-mail to: <[hidden email]>
>     > > Send administrative queries to  <[hidden email]
> >
>     >
>     >
>     > #############################################################
>     >
>     > This message is sent to you because you are subscribed to
>     >   the mailing list Lasso [hidden email]
>     > Official list archives available at http://www.lassotalk.com
>     > To unsubscribe, E-mail to: <[hidden email]>
>     > Send administrative queries to  <[hidden email]>
>
>     #############################################################
>
>     This message is sent to you because you are subscribed to
>       the mailing list Lasso [hidden email]
>     Official list archives available at http://www.lassotalk.com
>     To unsubscribe, E-mail to: <[hidden email]>
>     Send administrative queries to  <[hidden email]>
>
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>   the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Extract data from API

Jolle Carlestam-2
In reply to this post by French, Shelane
I’m with Shelane on this one. This is JSON data Laurent is getting from the service. He should learn use the proper tools to deal with it. Regex is not the best approach in handling JSON. Lasso has excellent tools in form of the JSON decoding and encoding methods. Using JSON decoding he gets a map that he can do whatever he needs to using usual map methods.

Laurent, JSON is everywhere today. Get a grip on how it’s constructed and take a look at lassos methods to handle it. It will be of great benefit for your future endeavours.

HDB
Jolle

> 10 jan. 2019 kl. 21:40 skrev French, Shelane <[hidden email]>:
>
> That's seriously over complicating it...


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>