Populating more variables through HTTP communication processor

Questions and answers on how to get the most out of FFAStrans
Post Reply
artmit
Posts: 7
Joined: Wed Feb 06, 2019 9:56 pm

Populating more variables through HTTP communication processor

Post by artmit »

Hello all,
First of all, I want to thank Steinar of making and maintenance this great software! I am quite new and just testing it, but it is really great work!

Back to subject - I trying to work with HTTP communicate processor. It allows populate single variable (BTW. not the first one on list of user variables, it seems like little bug ;) ), but I stucked on problem how to receive/decode (eg. from JSON response) more than 1 value.
For example: if response from another application through JSON will return:
{ 'val1' : 'first value content', 'val2' : 'second value content' }
I did not find any function in Populate Variables processor which can help me with that (besides using substring functions on static indexes) but it is of course impossible to predict length of first value etc.
Maybe someone already know solution and I just missed something really obvious in documentation?

Regards,
Artur
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: Populating more variables through HTTP communication processor

Post by emcodem »

Hi artmit,
great stuff, i like that you seem to have no big issues using ffastrans!
I can confirm there seems to be a bug using "the first uservariable" in the HTTP Communicate processor - Dropdown to select the user variable to polulate. The first user var in the list just don't seem to Show up, or better Shows up with an emtpy Name. @steinar will be interested in that one...

Second, can you live with a simple between function? .. e.g. if my json Looks like that:

Code: Select all

{"something":"notinterestingvalue","Connection":"value_to_parse","somethingelse":"notinterestingvalue"}
In a populate variables processor, i could use like that to get the first occurence of the value value "value_to_parse"

Code: Select all

$between("%s_restcontent2%", "Connection"":""", """,",1)
Note that doublequotes are escaped with another doublequote instead of the typical backslash...

To define it a Little better, your workflow Looks like this:
HTTP Call (populate result to variable) -> Populate Variables (parse and populate all the values you like into different user variables)

cheers,
emcodem
emcodem, wrapping since 2009 you got the rhyme?
artmit
Posts: 7
Joined: Wed Feb 06, 2019 9:56 pm

Re: Populating more variables through HTTP communication processor

Post by artmit »

Hi emcodem,
I've just put some specially-designed unused variable there as first in list, to fill the gap :-)

Good tip, thanks! Of course I also thought now that this way I can setup some more Populate Variables processors to get next values!

Thanks!
Artur
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: Populating more variables through HTTP communication processor

Post by emcodem »

artmit wrote: Thu Feb 07, 2019 11:22 am Of course I also thought now that this way I can setup some more Populate Variables processors to get next values!
Not sure if you got that so just to be sure: a single populate variables processor allows you to define and parse 7 different values from your JSON. How many values do you need to parse? :-)

cheers!
emcodem
emcodem, wrapping since 2009 you got the rhyme?
artmit
Posts: 7
Joined: Wed Feb 06, 2019 9:56 pm

Re: Populating more variables through HTTP communication processor

Post by artmit »

Ok :-) I forgot that there are more fields to be filled in :-)
Thanks!
Artur
admin
Site Admin
Posts: 1687
Joined: Sat Feb 08, 2014 10:39 pm

Re: Populating more variables through HTTP communication processor

Post by admin »

Hi Artur, thank you for using FFAStrans and welcome to the forum! :-)

In your case you might want to use single quotes when encapsulating text containting double quotes. It's easier to deal with.

$between("%s_get_day%", 'Connection":"', '","',1)


Also, thanks for reporting the variable issue. I will investigate.


-steinar
artmit
Posts: 7
Joined: Wed Feb 06, 2019 9:56 pm

Re: Populating more variables through HTTP communication processor

Post by artmit »

Yes, much easier! :D At least, it work only if use single-quotes on inputs string parameter - as inside there are double quotes already included.
Many thanks for help!
Artur
artmit
Posts: 7
Joined: Wed Feb 06, 2019 9:56 pm

Re: Populating more variables through HTTP communication processor

Post by artmit »

Ok, I eventually found proper function for it:

Code: Select all

$readarray()
Thought there has to be something ;)
Post Reply