Look up multiple e-mail addresses by deserializing JSON with regex - arrays

We are working on an application that retrieves data from an external source. By processing the data the JSON must be manipulated before deserializing . So far so good.
A problem occurs when a JSON element contains multiple values. For example:
"CcRecipients":[{"EmailAddress":{"Address":"foo#example.com","Name":"FirstName
LastName"}},{"EmailAddress":{"Address":"bar#example.com","Name":"FirstName1
LastName1"}}],
What we are looking for is an regex that will retrieve all occurrences of
{"EmailAddress":{"Address":"foo#example.com","Name":"FirstName LastName"}},
I've already created a regex for a single occurence:
(\[\{"\w+":\{"\w+":"\w+#\w+\d.\w+.\w{3}","\w{4}":"\w+\s+\w+"\}\},\])
Anyone an idea? Thanks in advance!

\d is not required. Also you need to escape ..
Can you try this:
input.match(/{"\w+":{"\w+":"\w+#\w+\.\w{3}","\w{4}":"\w+\s+\w+"}}/g);

Related

Extract components of a nested Array/STRUCT JSON string field in BigQuery

I have a String field in JSON format that I am trying to extract the stripe decline code from. An example of the field is below:
{"errors":[{"message":"Your card has insufficient funds.","type":"payment","code":"card_declined","decline_code":"insufficient_funds","gateway":"stripe","stripe":{"type":"card_error","code":"card_declined","decline_code":"insufficient_funds","message":"Your card has insufficient funds.","charge":"ch_3JodUAHkqql8g8ta1ADf5fBf"}}]}
I have tried various combinations of UNNEST but continue to get an error message. I think that the issue is related to the fact the field is a combination of various STRUCTS/Arrays but had no luck extracting what I need. Any help would be greatly appreciated!
I think I found a solution. A little hacky, but I did the following in a CTE;
REPLACE(REPLACE(JSON_EXTRACT(error_message, '$.errors'),"[",""),"]","") as struct_1
And then took another JSON_EXTRACT of this;
JSON_EXTRACT(struct_1,'$.stripe.decline_code')
Consider below approach - non hacky one :o)
select json_extract_scalar(error, '$.stripe.decline_code') as decline_code
from your_table,
unnest(json_extract_array(error_message, '$.errors')) error
if applied to sample data in your question - the output is

Looping with multiple variables in a URL using Postman

Using postman tool, I am trying to loop in multiple values in the place of a specific parameter 'memid' in the sample URL https://www.testdomain.com/login?memid=123
I have replaced the value '123' as {{id}} in the URL and then declared a single value '123' in Globals. It's working fine when I execute this. But, is there a way where I can loop the URL and replace the variable memid every time with some other predefined unique values? Should I be storing all the values in a separate csv file?? Thanks in advance.
You could take a look at using a Data file in the Collection Runner to help with this - More information can be found here.
https://learning.getpostman.com/docs/postman/collection_runs/working_with_data_files/

How to extract the data from IBMKeyword in UiPath?

I am experimenting with the IBM Watson NLU’s Text Analysis package in UiPath with a simple text. I am able to extract the KeyValue pair information for Categories, Concept, and Sentiments using .ToString() . However, I am having trouble in figuring out how to extract information for Keywords, Entity both are of type IBMKeyword, IBMEntity
A simple .ToString() method in the message box gives something that's not helping or I don't know how to use it.
Below is the screenshot of my UiPath Studio:
Try this. Since the variable has multiple keywords, it cannot be printed in a single message box without a loop

Regex to extract data in cell and pass to subsequent request where it is needed in Jmeter

I am using this regex to extract data in cell and pass to subsequent request where it is needed in JMeter.
Using Reg-ex to extract the data in cell:
"cell":\["","(.*?)","(.*?)","(.*?)","(.*?)","(.*?)","(.*?)","(.*?)","(.*?)","(.*?)","","(.*?)","(.*?)","(.*?)"]}]}
Can someone help to enhance it using beanshell or store it in array and then pass it to subsequent request?
It seems you are trying to extract something from JSON response. Using regular expressions for this is not very recommended.
Be aware that starting from JMeter 3.0 there is a JSON Extractor which can be used for fetching data from JSON responses using JsonPath language.
The relevant JsonPath expression to get the content of cell element will be as simple as:
$..cell
Going forward please try to include at least essential parts of the response into your question.

Create a corpus with a single file (webpage)

I want to read a single file (the file is a html document) from my computer and store it in a Corpus (I'm using the package tm).
Do you have any solution to do that?
Here is what I tried :
data<-read.csv(fileName)
c2<-Corpus(VectorSource(data))
it mostly works, but I sometime get the error : more columns than column names
I guess I'm not supposed to use read.csv for a webpage, as I didn't find a better solution.
Thanks for your help =)
A webpage definitely does not conform to the specifications that a CSV should. Instead you probably want to use the readHTMLTable function from the XML package.
This is grabbing from an actual webpage but it should be the same idea
file <- "http://xkcd.com/"
dat <- readLines(file)
c2 <- Corpus(VectorSource(dat))

Resources