Page 1 of 1
Populating more variables through HTTP communication processor
Posted: Wed Feb 06, 2019 11:24 pm
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
Re: Populating more variables through HTTP communication processor
Posted: Thu Feb 07, 2019 8:31 am
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
Re: Populating more variables through HTTP communication processor
Posted: Thu Feb 07, 2019 11:22 am
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
Re: Populating more variables through HTTP communication processor
Posted: Thu Feb 07, 2019 12:12 pm
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
Re: Populating more variables through HTTP communication processor
Posted: Thu Feb 07, 2019 7:57 pm
by artmit
Ok
I forgot that there are more fields to be filled in
Thanks!
Artur
Re: Populating more variables through HTTP communication processor
Posted: Fri Feb 08, 2019 8:10 pm
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
Re: Populating more variables through HTTP communication processor
Posted: Fri Feb 08, 2019 8:42 pm
by artmit
Yes, much easier!
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
Re: Populating more variables through HTTP communication processor
Posted: Sat Feb 09, 2019 6:55 pm
by artmit
Ok, I eventually found proper function for it:
Thought there has to be something